PM2检查进程状态并重启

pm2 delete
pm2 start
pm2 stop
pm2 restart

主要针对delete错误或者stop错误,不往后执行的问题

最优解决方案

# The || : part executes if the pm2 delete sets a non-zero return code
# (which happens when try to delete an app that does not exist yet).
# The : is a null operator that returns 0 success exit code. So whatever happens, the pm2 start line is executed.
pm2 delete -s 'celerpay-official-site' || :
pm2 start npm --name 'celerpay-official-site' -- run start"$0"

你可能感兴趣的:(PM2检查进程状态并重启)