我有一个简单的 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
。
那么,我的配置有什么问题?