I'm trying to use pm2 to manage a node.js cluster
pm2 start . -i 3
I'm currently running the app on heroku and using a Procfile with the above command, but I cannot figure out how to configure pm2 to use the existing PORT env var. Something like pm2 start . -p $PORT
What am I missing?
You can use environment variable. For example:
1) NODE_PORT=3002 pm2 start -I 0 app.js
2) Read value in app:
console.log(process.env.NODE_PORT);
Or, if you are build express app:
1) PORT=3002 pm2 start -I 0 ./bin/www
2) Express load PORT automatically at start application.
You need to use -- to tell pm2 to stop parsing his options and give the rest to the program, then when you spawn direct binary, you need to tell pm2 that you don't want to use nodejs, so :
pm2 start rethinkdb --interpreter none -- --port 8082
You see you need -- --port 8082
来源:https://stackoverflow.com/questions/31502351/how-to-specify-a-port-number-for-pm2