PM2检查进程状态并重启

pm2 delete <name>
pm2 start <name>
pm2 stop <name>
pm2 restart <name>

主要针对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"
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。