我希望payara服务器作为服务运行。我以sudo的身份登录asadmin,并使用create-service命令。给出了以下输出。
The Service was created successfully. Here are the details:
Name of the service:production
Type of the service:Domain
Configuration location of the service:/etc/init.d/payara_production
User account that will run the service: root
You have created the service but you need to start it yourself. Here are the most typical Linux commands of interest:
* /etc/init.d/payara_production start
* /etc/init.d/payara_production stop
* /etc/init.d/payara_production restart
For your convenience this message has also been saved to this file:
/home/buddhika/payara/glassfish/domains/production/PlatformServices.log
Command create-service executed successfully.
这将在 /etc/init.d/ 文件夹中创建payara_production脚本,但一旦重新启动计算机,就不会执行此脚本。我必须手动启动payara才能运行它。
“您已经创建了服务,但是您需要自己启动它”是什么意思,我在之前使用的GlassFish版本中没有类似的问题。
如何将Payara作为服务启动?
Payara Server(以及GlassFish)使用System V机制创建服务。这种机制已经过时,并且不被更新的Linux系统很好地支持。大多数现代Linux发行版使用SystemD,它支持使用system
命令启动/停止System V服务,但不支持在引导时直接启用它们而不进行任何修改。
您的 Linux 发行版最有可能使用 SystemD。若要在启动时运行服务,可以遵循以下指南:https://linoxide.com/linux-how-to/enable-disable-services-ubuntu-systemd-upstart/。如果您有机会访问Payara支持门户,则可以按照以下详细指南进行操作:https://support.payara.fish/hc/en-gb/articles/360034527494-Configure-a-Payara-Server-Domain-as-a-System-Service
简而言之,您需要在/etc/systemd/system/
或systemd需要的任何其他文件夹中创建服务
。该文件应包含启动服务的ExecStart
指令,在本例中为/etc/init。d/payara_。如果希望它在启动时启动,也在崩溃后启动,请添加“Restart=always”指令。
如果您的服务文件名为payara。服务
,您可以在启动时通过以下方式启用服务:
sudo systemctl enable payara
编辑:
或者,如果您修改脚本以在注释中添加一些标头,则可以使用 SystemD 运行 Payara Server 在引导时创建的服务,如下所述:https://serverfault.com/questions/849507/systemctl-不识别-我的-服务-默认-启动-包含-无-运行级别-abo
例如,将此注释添加到#的正下方/bin/sh
行:
### BEGIN INIT INFO
# Provides: payara_production
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: your description here
### END INIT INFO
然后,您可以使用SystemD命令安装它:
systemctl enable payara_production.service