【发布时间】:2016-04-21 15:17:09
【问题描述】:
在服务器重新启动时,我很难让 pm2 重新启动(它本身和两个节点/express 文件,app.js 和 app2.js)。
以下是我尝试过的流程:
pm2 startup
pm2 start app.js
pm2 start app2.js
pm2 startup ubuntu (also tried systemd and with/without -u username)
pm2 save
我以所有可能的组合运行了上述命令,但没有任何效果。我尝试以 root 身份运行,但它也不起作用。
我的~/.pm2/dump.pm2 文件包含信息,所以我不知道该去哪里找。
我曾尝试根据this issue 修改我的/etc/init.d/pm2-init.sh 文件,但没有帮助。
我的设置:
数字海洋服务器
Ubuntu 15.10
节点 v5.4.1
PM2 v 1.0.0
我尝试过的其他参考..
http://pm2.keymetrics.io/docs/usage/startup/
https://www.digitalocean.com/community/tutorials/how-to-use-pm2-to-setup-a-node-js-production-environment-on-an-ubuntu-vps
https://gist.github.com/leommoore/5998406
https://www.terlici.com/2015/06/20/running-node-forever.html
https://serversforhackers.com/node-process-management-with-pm2
http://nodered.org/docs/getting-started/running.html#starting-node-red-on-boot
https://github.com/Unitech/pm2/issues/1316
到目前为止,每次我重新启动服务器时,pm2 都无法自动启动(除非我需要等待几分钟?- nginx 会立即重新启动)。
有人可以帮我解决这个问题吗?命令的运行顺序是什么?我需要修改任何其他文件吗?
【问题讨论】: