Hitu Bansal Hitu Bansal - 3 months ago 33
Node.js Question

How to start node.js app with pm2 in cluster mode?

We are trying to start our app with pm2 0.12.8 on ubuntu 14.04 with octa core proccessor. The read me on the git hub has a very straight forward command for running node app in cluster mode.

# Cluster mode

$ pm2 start app.js -i 0 **# Will start maximum processes with LB depending on available CPUs**
$ pm2 start app.js -i max **# Same as above, but deprecated yet.**

But the above command are not working for us. When we try to run these commands only one instance is listed by pm2.

Any suggestion



have you tried starting a fixed number of processes? i.e.

pm2 start app.js -i 2 //should start two instances.

what does "pm2 monit" show you?

also try

pm2 stop all
pm2 delete all 

and then

pm2 start app.js -i 0

if you stop a process in pm2 it still reserves one cpu for it even if its not running. you should allways use pm2 delete