PM2 cluster mode only starts one instance
Asked Answered
V

3

7

I'm using PM2 for clustering. It worked just fine when using NodeJS 0.10.31 and PM2 0.12.14. I upgraded NodeJS to 0.12.4 and PM2 to 0.12.16 and now when launching the following command :

pm2 start app.js -i 5

I get :

[PM2] Spawning PM2 daemon

[PM2] PM2 Successfully daemonized

[PM2] Process app.js launched

│ app      │ 0  │ cluster │ 1372 │ online │ 0       │ 0s     │ 30.500 MB   │ disabled │

I expected 5 clusters but I get only one (one row in the table). I didn't see anything in the logs so far. Any idea ?

Velutinous answered 10/6, 2015 at 15:2 Comment(0)
A
2

You should not use cluster mode with Node 0.10.x

Adp answered 22/7, 2015 at 10:50 Comment(0)
S
20

If you've previously run the "pm2 start .. " command, pm2 will maintain the number of instances you specified in that command.

Running "pm2 delete all" and then "pm2 start app.js -i 5" should start five instances.

Solleret answered 27/7, 2016 at 23:32 Comment(2)
Worked like a charm for me. ThanksTuttifrutti
Spent a couple hours trying to figure this out. Thanks for the info! Feels like a (super old) bug though... shouldn't it honor the number of instances if you start it again later with a different configuration?Kassala
O
2

I had the same issue. I had to start my application like:

pm2 start test.js -i 0 --no-daemon

And started all the processes. I have no idea why this happens.

By the way, requests are not balanced across all processes, all requests are handled by one process; I'm still checking why this happens.

Oops answered 3/7, 2015 at 10:48 Comment(1)
Hello @guiness , I am running into the same issue, I mean the "requests are not balanced across all processes, all requests are handled by one process;" If you don't mind can I know the reason in case you remember? Thank YouAlfonse
A
2

You should not use cluster mode with Node 0.10.x

Adp answered 22/7, 2015 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.