gpt4 book ai didi

node.js - 无法使用 systemctl 永远启动进程

转载 作者:行者123 更新时间:2023-12-04 19:42:55 25 4
gpt4 key购买 nike

我有一个简单的 Node/Express 服务器永远运行

forever start forever_app_config.json

我的配置文件看起来像这样
{
"uid": "myapp",
"append": true,
"watch": true,
"script": "app.js",
"sourceDir": "/data/projects/myapp"
}

一切正常。但是在尝试添加服务时( /usr/lib/systemd/system/mayapp.service)
[Unit]
Description = My Service

[Service]
User = centos
Group = centos
Environment = NODE_ENV=production
Environment = PORT=3333
ExecStart = /usr/bin/forever start /data/projects/myapp/forever_app_config.json
ExecStop = /usr/bin/forever stop myapp

[Install]
WantedBy = multi-user.target

由于某种原因它不起作用: sudo systemctl start myapp -l
myapp.service - My Service
Loaded: loaded (/usr/lib/systemd/system/myapp.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Mon 2018-02-19 11:43:08 UTC; 12min ago
Process: 26685 ExecStop=/usr/bin/forever stop malcazar (code=exited, status=0/SUCCESS)
Process: 26674 ExecStart=/usr/bin/forever start /data/projects/myapp/forever_app_config.json (code=exited, status=0/SUCCESS)
Main PID: 26674 (code=exited, status=0/SUCCESS)

和永远的日志( /home/centos/.forever/myapp.log )显示这样的错误: error: Forever detected script was killed by signal: SIGKILL .

那么,我的配置有什么问题?

最佳答案

最奇怪的是通过重新安装foreverjs解决了一个问题

● myapp.service - My Service
Loaded: loaded (/usr/lib/systemd/system/myapp.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2018-02-22 17:37:43 UTC; 4min 17s ago
Main PID: 8121 (node)
CGroup: /system.slice/myapp.service
├─8121 node /usr/bin/forever /data/projects/myapp/forever_app_config.json
└─8244 /usr/bin/node /data/projects/myapp/app.js

我几乎可以肯定情况并非如此 sudo npm install forever -g ,但它现在对我有用,所以结束了这个问题。

关于node.js - 无法使用 systemctl 永远启动进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48865777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com