pm2 (v2.4.0) deletes all processes after pm2 restart/stop <process-name>

Created on 13 Feb 2017  路  2Comments  路  Source: Unitech/pm2

I just updated my pm2 version from v1 to v2.4.0 and usually pm2 restart api successfully restarts my api process.

pm2 restart api is now unresponsive (it freezes) after entering the command!

After running this command, I also noticed the process that were initially running are now deleted.

pm2 logs:

PM2        | Stopping app:api id:1
PM2        | ===============================================================================
PM2        | --- PM2 global error caught ---------------------------------------------------
PM2        | Time                 : Mon Feb 13 2017 20:25:07 GMT+0000 (UTC)
PM2        | Cannot read property 'forEach' of null
PM2        | TypeError: Cannot read property 'forEach' of null
PM2        |     at ChildProcess.onClose (/usr/lib/node_modules/pm2/lib/TreeKill.js:104:26)
PM2        |     at emitTwo (events.js:106:13)
PM2        |     at ChildProcess.emit (events.js:191:7)
PM2        |     at maybeClose (internal/child_process.js:877:16)
PM2        |     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Software versions used

OS         : Amazon linux
node.js    : v6.9.0
PM2        : v2.4.0

PM2 Log output

[ec2-user~]$ tail --lines 50 ~/.pm2/pm2.log
2017-02-13 20:24:35: Starting execution sequence in -fork mode- for app name:api id:1
2017-02-13 20:24:35: App name:realtime id:0 online
2017-02-13 20:24:35: App name:api id:1 online
2017-02-13 20:24:35: Starting execution sequence in -fork mode- for app name:githook id:2
2017-02-13 20:24:35: App name:githook id:2 online
2017-02-13 20:25:07: Stopping app:githook id:2
2017-02-13 20:25:07: ===============================================================================
2017-02-13 20:25:07: --- PM2 global error caught ---------------------------------------------------
2017-02-13 20:25:07: Time                 : Mon Feb 13 2017 20:25:07 GMT+0000 (UTC)
2017-02-13 20:25:07: Cannot read property 'forEach' of null
2017-02-13 20:25:07: TypeError: Cannot read property 'forEach' of null
    at ChildProcess.onClose (/usr/lib/node_modules/pm2/lib/TreeKill.js:104:26)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
2017-02-13 20:25:07: ===============================================================================
2017-02-13 20:25:07: [PM2][%s] Resurrecting PM2
Be sure to have the latest version by doing `npm install pm2@latest -g` before doing this procedure.
[PM2] Saving current process list...
[PM2] Stopping PM2...
[PM2] Applying action deleteProcessId on app [all](ids: 0,1,2)
2017-02-13 20:25:08: Stopping app:realtime id:0
2017-02-13 20:25:08: Stopping app:api id:1
2017-02-13 20:25:08: Stopping app:githook id:2
/usr/lib/node_modules/pm2/lib/TreeKill.js:104
    allData.match(/\d+/g).forEach(function (pid) {
                         ^

TypeError: Cannot read property 'forEach' of null
    at ChildProcess.onClose (/usr/lib/node_modules/pm2/lib/TreeKill.js:104:26)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
2017-02-13 20:26:07: ===============================================================================
2017-02-13 20:26:07: --- New PM2 Daemon started ----------------------------------------------------
2017-02-13 20:26:07: Time                 : Mon Feb 13 2017 20:26:07 GMT+0000 (UTC)
2017-02-13 20:26:07: PM2 version          : 2.4.0
2017-02-13 20:26:07: Node.js version      : 6.9.5
2017-02-13 20:26:07: Current arch         : x64
2017-02-13 20:26:07: PM2 home             : /home/ec2-user/.pm2
2017-02-13 20:26:07: PM2 PID file         : /home/ec2-user/.pm2/pm2.pid
2017-02-13 20:26:07: RPC socket file      : /home/ec2-user/.pm2/rpc.sock
2017-02-13 20:26:07: BUS socket file      : /home/ec2-user/.pm2/pub.sock
2017-02-13 20:26:07: Application log path : /home/ec2-user/.pm2/logs
2017-02-13 20:26:07: Process dump file    : /home/ec2-user/.pm2/dump.pm2
2017-02-13 20:26:07: Concurrent actions   : 2
2017-02-13 20:26:07: SIGTERM timeout      : 1600
2017-02-13 20:26:07: ===============================================================================
Pending Release API Bug

Most helpful comment

Released in pm2 2.4.1

All 2 comments

Released in pm2 2.4.1

Very useful, thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

waygee picture waygee  路  4Comments

alexpts picture alexpts  路  3Comments

psparago picture psparago  路  3Comments

chaos-git picture chaos-git  路  3Comments

lefam picture lefam  路  3Comments