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?
Inside ecosystem. config. js you specify one entry object for each server instance you want to launch through PM2. The point is that you can also specify environment vars for the different processes and that way you can setup $PORT for all the processes.
Starting from PM2 3.2, we changed the networking connection by using a direct Websocket connection to our server on the port 443, so you only need OUTBOUND on port 443 TCP open.
The default configuration file is ecosystem. core3. config. js , and is located in the root folder of lisk-service : It contains a configuration to connect to a local Lisk Core node.
You can use environment variable. For example:
NODE_PORT=3002 pm2 start -i 0 app.js
Read value in app:
console.log(process.env.NODE_PORT);
Or, if you are build express app:
PORT=3002 pm2 start -i 0 ./bin/www
Express load PORT automatically at start application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With