无法使用 systemctl 启动永久进程
Cannot launch forever process with systemctl
我有一个简单的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
,但它现在对我有用,所以结束这个问题。
我已通过迁移到 pm2
而不是永远使用来解决问题。
http://pm2.keymetrics.io/docs/usage/quick-start/
我有一个简单的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
,但它现在对我有用,所以结束这个问题。
我已通过迁移到 pm2
而不是永远使用来解决问题。
http://pm2.keymetrics.io/docs/usage/quick-start/