我想让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作为一项服务?
发布于 2020-08-24 08:36:03
Payara (以及GlassFish)使用System机制创建服务。这种机制已经过时,新的Linux系统并不能很好地支持它。大多数现代的Linux发行版都使用SystemD,它支持使用system命令启动/停止System服务,但不需要修改就直接启用它们。
您的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
简而言之,您需要在service或任何其他SystemD期望的文件夹中创建一个SystemD文件。这个文件应该包含启动服务的ExecStart指令,在您的例子中是/etc/init.d/payara_production start。如果您希望它在崩溃后也在引导时启动,请添加`Restart=always“指令”。
如果您的服务文件名为payara.service,则可以在引导时使用以下方式启用服务:
sudo systemctl enable payara编辑:
或者,如果您修改脚本以在注释中添加一些标头,则可以使用SystemD在启动时运行Payara创建的服务,如下所述:https://serverfault.com/questions/849507/systemctl-doesnt-recognize-my-service-default-start-contains-no-runlevels-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.servicehttps://stackoverflow.com/questions/63511583
复制相似问题