简体   繁体   中英

error starting pm2 in cluster mode in windows

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:\Use rs\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\pbai d\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\Meth ods.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.

I solved this issue on windows by going to the services and stop the pm2 service from running and at my terminal, I did the pm2 start app.js and everything ran fine

解决方法很简单:重启电脑或服务器。

在 Windows 上,不要使用集群:

pm2 start "filename.js"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM