Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting Pm2 in auto cluster mode #38

Open
shaunakv1 opened this issue Apr 25, 2018 · 4 comments
Open

Starting Pm2 in auto cluster mode #38

shaunakv1 opened this issue Apr 25, 2018 · 4 comments

Comments

@shaunakv1
Copy link

shaunakv1 commented Apr 25, 2018

Hello,

I am using the v8.9.4 node image. I am trying to figure out how to get pm2 to start in built-in cluster mode. If I scale up my app service plan I can actually have more CPU. I want to get pm2 to spin up more clusters. this command pm2 start app.js -i max auto detects the number of CPUs and spins up right number of node instances.

This should in theory be transparent to the web app. I tried to spin up the cluster manually by running that command straight in console, and they spin up alright. Also use up CPU much better.

How can I use the current container to start my application using pm2 in cluster mode?

Thanks!

@tony-gutierrez
Copy link

tony-gutierrez commented Jun 20, 2018

You need to set the nodeProcessCountPerApplication to 0 in iisnode.yml in your root.
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml

@shaunakv1
Copy link
Author

I am not using the windows azure web app. I use the nodejs container which does not use IIS.

@tony-gutierrez
Copy link

tony-gutierrez commented Jun 22, 2018

Hmm, theres probably somewhere where you can relay config flags to PM2, but I am not familiar with it. Perhaps you can configure this in the process.json file?

#10

http://pm2.keymetrics.io/docs/usage/application-declaration/#process-file

@techno246
Copy link

It appears that if you set your startup file to process.json, it will start PM2 in cluster. You can then set the number of instances in process.json.

{
  "name": "worker",
  "script": "./server.js",
  "instances": 4,
  "merge_logs": true,
  "log_date_format": "YYYY-MM-DD HH:mm Z",
  "watch": true,
  "watch_options": {
    "followSymlinks": true,
    "usePolling": true,
    "interval": 5
  }
}

Logs here https://gist.github.com/techno246/fbe2de3b3521464b549d3498e2b0ac03 (same one I posted in issue #47 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants