Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PM2 cluster mode only starts one instance

Tags:

node.js

pm2

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 ?

like image 459
Kwel Avatar asked Jun 10 '15 15:06

Kwel


People also ask

How do I run multiple PM2?

Running Multiple PM2 If you want to run multiple PM2 under the same user, you can override the variable PM2_HOME . Setting the PM2_HOME will change the PM2 configuration folder, like communication sockets ( $HOME/. pm2/pub. sock and $HOME/.

How does PM2 cluster mode work?

PM2 is a Production Process Manager for Node. js applications with a built-in Load Balancer. When properly configured, PM2 will automatically run your app in cluster mode, spawn workers for you, and take care of spawning new workers when a worker dies.

Is PM2 multithreaded?

PM2 is an open-source distributed multithreaded programming environment designed to support efficiently distributed programs with a highly irregular behavior (e.g. branch and bound search, computation on sparse matrices, etc.)


2 Answers

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.

like image 119
snazziness Avatar answered Oct 09 '22 09:10

snazziness


You should not use cluster mode with Node 0.10.x

like image 25
Unitech Avatar answered Oct 09 '22 11:10

Unitech