Node - Trying to restart using Forever won't work in bash script on cronjob

这一生的挚爱 提交于 2019-12-06 13:38:53

forever is generally limited to processes owned by the current user. If the user firing the cron job is not the same user that originally started the process, then forever stopall will not find any PIDs to kill.

For example, I execute all of my node apps using a user called "nodejs". If I'm using the system interactively, I can use sudo -H -u nodejs forever list. And on root crons or /etc/rc.local, I will use su - nodejs -c "forever start /path/to/app.js"

I haven't tested it, but you might want to look into some of forever's options such as the --exitcrash flag.

Forever has issues when dealing with other programs that automatically restart your server. While not specific to Chron, this link might help.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!