【问题标题】:Cpanel - Startup ScriptCpanel - 启动脚本
【发布时间】:2018-04-27 20:04:10
【问题描述】:

当他们使用 Cpanel 或 WHM 重新启动服务器时,如何获取 java 命令?我有一个 spring boot 应用程序正在运行(使用 java -jar jarname.jar 启动它。当我重新启动 Cpanel 时,我必须手动运行脚本。我怎样才能让它在 Cpanel 或 Centos7 重新启动时自动运行命令?我安装了 java作为根,所以我不知道这是否意味着我必须将它作为 Centos7 脚本而不是某种 Cpanel 脚本运行。

我目前在使用 centos7 systemctl 服务时遇到的错误:

blah.service - Startsspring boot
Loaded: loaded (/etc/systemd/system/blah.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Fri 2018-04-27 19:19:47 EDT; 2s ago
Process: 3642 ExecStart=/usr/bin/bash /usr/bin/blah.sh (code=exited, status=0/SUCCESS)
Main PID: 3642 (code=exited, status=0/SUCCESS)

Apr 27 19:19:47 server systemd[1]: Started Starts spring boot.
Apr 27 19:19:47 server systemd[1]: Starting Starts spring boot...

这就是我得到的所有帮助都说它启动了,但服务从不启动我的 jar 它说不活动:(

启动脚本:

[Unit]
Description=Starts spring boot
After=network.target
[Service]
ExecStart=/usr/bin/bash /usr/bin/blah.sh
Type=simple
User=root
[Install]
WantedBy=multi-user.target

.sh 文件(如果我在命令行运行它就可以正常工作)

/usr/bin/nohup /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java -jar /home/domain/public_html/jarname.jar &

谢谢, 布赖恩

【问题讨论】:

    标签: cpanel centos7 whm


    【解决方案1】:

    我在这里找到了解决方案。我只是在 systemd 服务中执行了 java 命令,而不是在 shell 脚本中。

    https://techdev.io/en/developer-blog/jvm-applications-as-a-service-with-systemd

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-10
      • 2012-11-05
      • 2013-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多