• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
梧桐爱凤
博客园    首页    新随笔    联系   管理    订阅  订阅

[批处理]守护NodeJS进程

背景:

日常进行CI过程中,使用NodeJs方式:GIT更新->检测是否需要编译->调用IncrediBuilder编译->读取编译日志判断是否通过->调用7z打包

问题:

持续进行一天(约18)小时候,会报错:JavaScript heap out of memory

尝试方式:

1、使用 --max-memory-restart 

cmd /c pm2 start demo.js --max-memory-restart 4096M

 

2、启动检测批处理,并定时杀死NodeJs进程

:next
tasklist|find /i "node.exe" && (goto save)
echo %date%%time%"重启"
pm2 resurrect
echo %date%%time%"等待10分钟"
ping 127.0.0.1 -n 600 >1.txt
del 1.txt
:save
echo %date%%time%"正常"
pm2 save
ping 127.0.0.1 -n 600 >1.txt
del 1.txt
goto next

 

taskkill /F /IM node.exe

 

注意事项:

1、出现:connect EPERM //./pipe/rpc.sock,解决方案:杀死进程,删除pm2.log 重启pm2

 

每多学一点知识,就少写一行代码
posted @ 2019-03-28 09:12  梧桐爱凤  阅读(679)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3