技术分享1 分钟阅读
serv00使用PM2保活程序
PM2 是一个流行的 Node.js 应用程序的进程管理工具。serv00会不定时的重启,导致启动程序掉线。用PM2加定时任务可以实现保活和自动重启。
安装PM2
bash <(curl -s https://raw.githubusercontent.com/k0baya/alist_repl/main/serv00/install-pm2.sh)PM2使用:
使用pm2启动应用
pm2 start (xxx为原始业务启动命令)保存pm2进程列表
pm2 save重新加载pm2管理的进程
pm2 resurrect定时任务脚本
#保活检测脚本,添加到定时任务一分钟执行一次
output=$(/home/xxxx/.npm-global/bin/pm2 status)
if echo "$output" | grep -q "Current process list is not synchronized with saved list"; then
echo "Process list is not synchronized. Executing pm2 resurrect..."
/home/xxxx/.npm-global/bin/pm2 resurrect
else
echo "Process list is synchronized."
fi有关使用上的问题,欢迎您在底部评论区留言,一起交流~
读者评论
评论会同步写入该文在 Notion 中的页面底部(与正文同页,便于管理)。
暂无评论,欢迎抢沙发。