【问题标题】:Payara Server Start as a servicePayara 服务器作为服务启动
【发布时间】:2020-12-10 04:11:21
【问题描述】:

我希望 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 作为服务启动?

【问题讨论】:

    标签: glassfish payara


    【解决方案1】:

    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 期望的任何其他文件夹中创建一个 service 文件。此文件应包含启动服务的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.service
    

    【讨论】:

      猜你喜欢
      • 2020-07-16
      • 1970-01-01
      • 2018-07-17
      • 2016-03-04
      • 2018-09-14
      • 1970-01-01
      • 2017-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多