I am getting an error while starting pm2 in cluster mode. I ran this command -
pm2 start <filename> -i 4
Only one instance gets created. I am using Windows 7, Node 0.12.0 and pm2 0.14.0
This is my error log
2015-06-18 10:52:04: [PM2][WORKER] Started with refreshing interval: 30000 2015-06-18 10:52:04: [[[[ PM2/God daemon launched ]]]] 2015-06-18 10:52:04: BUS system [READY] on port \.\pipe\pub.sock 2015-06-18 10:52:04: RPC interface [READY] on port \.\pipe\rpc.sock 2015-06-18 10:52:04: Starting execution sequence in -cluster mode- for app name:server id:0 2015-06-18 10:52:04: App name:server id:0 online 2015-06-18 10:52:04: Starting execution sequence in -cluster mode- for app name:server id:1 2015-06-18 10:52:04: Trace: { [Error: spawn EBADF] code: 'EBADF', errno: 'EBADF', syscall: 'spawn' } at Object.God.logAndGenerateError (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God\Methods.js:30:15) at Object.nodeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God\ClusterMode.js:52:11) at Object.executeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:145:9) at ex (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:361:18) at C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:365:16 at Worker.cluOnline (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:188:17) at Worker.g (events.js:199:16) at Worker.emit (events.js:104:17) at online (cluster.js:449:12) at Worker.onmessage (cluster.js:436:7) 2015-06-18 10:52:04: Starting execution sequence in -cluster mode- for app name:server id:2 2015-06-18 10:52:05: Trace: { [Error: spawn EBADF] code: 'EBADF', errno: 'EBADF', syscall: 'spawn' } at Object.God.logAndGenerateError (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God\Methods.js:30:15) at Object.nodeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God\ClusterMode.js:52:11) at Object.executeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:145:9) at ex (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:361:18) at C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:362:25 at nodeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:146:29) at Object.nodeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God\ClusterMode.js:53:14) at Object.executeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:145:9) at ex (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:361:18) at C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:365:16 2015-06-18 10:52:05: Starting execution sequence in -cluster mode- for app name:server id:3 2015-06-18 10:52:05: Trace: { [Error: spawn EBADF] code: 'EBADF', errno: 'EBADF', syscall: 'spawn' } at Object.God.logAndGenerateError (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God\Methods.js:30:15) at Object.nodeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God\ClusterMode.js:52:11) at Object.executeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:145:9) at ex (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:361:18) at C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:362:25 at nodeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:146:29) at Object.nodeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God\ClusterMode.js:53:14) at Object.executeApp (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:145:9) at ex (C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:361:18) at C:\Users\pbaid\AppData\Roaming\npm\node_modules\pm2\lib\God.js:362:25
I met this problem today too.
If I run "pm2 logs" before any other pm2 operation, and then start applications in cluster mode ("pm2 start app.js -i 4"), everything looks fine. It seems pm2 need some time for initialization. I have no idea about the real reason.
Looking forward for better solution too.