pm2守护进程挂掉是怎么回事?
发布于 1 天前 作者 zstxt1989 84 次浏览 来自 问答

昨天发生一起严重事故,不知什么原因,pm2挂掉了,所有node项目的服务都挂了。 应该是进程死掉了,手动把所有 node 进程kill掉,然后再一个个pm2 start 重启才恢复。 ps.查看进程还发现一个 pm2 update 一直卡在那。

查看pm2.log发现如下记录

2016-06-30 10:58:39: [PM2][WORKER] Process 6 restarted because it uses 0 memory and has ONLINE status
2016-06-30 10:58:39: Stopping app:cpaapi id:6
2016-06-30 10:58:39: App name:cpaapi id:6 disconnected
2016-06-30 10:58:39: [PM2] Error caught by domain:
Error: spawn /bin/sh EMFILE
	at exports._errnoException (util.js:896:11)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
	at onErrorNT (internal/child_process.js:348:16)
	at _combinedTickCallback (internal/process/next_tick.js:74:11)
	at process._tickDomainCallback (internal/process/next_tick.js:122:9)
2016-06-30 10:58:39: [PM2] Trying to update PM2...
2016-06-30 10:58:39: Process with pid 4571 still not killed, retrying...
2016-06-30 10:58:39: Process with pid 4571 still not killed, retrying...
2016-06-30 10:58:39: Process with pid 4571 still not killed, retrying...
2016-06-30 10:58:39: Process with pid 4571 still not killed, retrying...
2016-06-30 10:58:39: Process with pid 4571 still not killed, retrying...
2016-06-30 10:58:39: Process with pid 4571 still not killed, retrying...
2016-06-30 10:58:39: Process with pid 4571 still not killed, retrying...
Be sure to have the latest version by doing `npm install pm2@latest -g` before doing this procedure.
[PM2] Saving current process list...
2016-06-30 10:58:39: Process with pid 4571 still not killed, retrying...
[PM2] Stopping PM2...
[PM2] Applying action deleteProcessId on app [all](ids: 6,8,9,11)
2016-06-30 10:58:39: Stopping app:cpaapi id:6
/usr/local/nvm/versions/node/v6.0.0/lib/node_modules/.pm2_npminstall/pm2/1.1.3/pm2/lib/TreeKill.js:87
	  throw err;
	  ^

Error: spawn /bin/sh EMFILE
	at exports._errnoException (util.js:896:11)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
	at exports._errnoException (util.js:896:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
at onErrorNT (internal/child_process.js:348:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

请教各路大神怎么查找原因以及pm2挂掉怎么自动重启

回到顶部