You must especificate the file JSON wich have the proper configuration for your app wich environment do you want to use (declared in your ecosystem file).
pm2 start ecosystem_cluster_mode.json --env production
pm2 save (Autostart your application when PM2 service is started/restarted)
pm2 ls (Shows PM2 runnings apps)
netstat -ntpl | grep pm2 (Filter running PM2 applications)
Indicates wich configuration use for your new ecosystem, more information at https://pm2.keymetrics.io/docs/usage/environment/
- env: Environment variables for developement
- env_production: Environment variables for production
Sometimes PM2 dont save correctly is configuration, so if the server was restarted your applications aren't going to autostart, to resolve this problem follow this steps (be careful with your others saved ecosystems, rm -rf ~/.pm2 has going to delete all your saved configurations from PM2).
# Stop and delete your app
pm2 stop app_name
pm2 delete app_name
# Kill PM2 process
ps -fea | grep pm2
kill -9 [PM2_PID]
rm -rf ~/.pm2
# Reconfigure the ecosystem for your app
pm2 start ecosystem_cluster_mode.json --env production
pm2 save
Create a separated instance for your app with N replicas, the parameter increment_var is used for asign a unique port number to every replica avoiding port crashs.
The cluster mode allows networked Node.js applications (http(s)/tcp/udp server) to be scaled accross all CPUs available, without any code modifications, the application port number is unique for the entire cluster.
I'm having this problem with a similar setup.
Unitech/pm2#5580
Could you maybe guide @caeb92?