Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to "npm start" with pm2 cluster mode

Tags:

node.js

pm2

this commend start pm2 with cluster mode.

$ pm2 start [app] -i 0

this commend npm start with pm2 process.

$ pm2 start npm -- start

So I want npm start of cluster mode.

$ pm2 start npm -- start -i 0

But "npm start" don't start cluster mode.

How to "npm start" with cluster mode on pm2 ?

like image 285
ATHeart Avatar asked Oct 24 '25 05:10

ATHeart


1 Answers

  1. the command line you have above does not seem to be correct. You wrote:

$ pm2 start npm -- start -i 0

it should be

$ pm2 start app.js -i 0

from the docs

  1. I would strongly suggest using a pm2.json configuration file so you can place all your needed parameters inside and start PM2 with the Json file.

  2. To check if PM2 is actually in cluster mode: PM2 list all or PM2 describe [name of app] This will show you detailed information on the running apps.

Hope this helps

like image 94
twg Avatar answered Oct 26 '25 19:10

twg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!