首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Payara服务器作为服务启动

Payara服务器作为服务启动
EN

Stack Overflow用户
提问于 2020-08-20 18:59:04
回答 1查看 2.4K关注 0票数 0

我想让payara服务器作为服务运行。我以sudo的身份登录到asadmin,并使用了create-service命令。给出了以下输出。

代码语言:javascript
复制
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作为一项服务?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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,则可以在引导时使用以下方式启用服务:

代码语言:javascript
复制
sudo systemctl enable payara

编辑:

或者,如果您修改脚本以在注释中添加一些标头,则可以使用SystemD在启动时运行Payara创建的服务,如下所述:https://serverfault.com/questions/849507/systemctl-doesnt-recognize-my-service-default-start-contains-no-runlevels-abo

例如,在#!/bin/sh行下面添加此注释:

代码语言:javascript
复制
### 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命令安装它:

代码语言:javascript
复制
systemctl enable payara_production.service
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63511583

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档