« »
4/11/2015

PM2 tips - uncommon ssh port, cluster_mode and deploy troubleshooting

Note: PM2 own code quality is bad and cluster_mode is not production ready. I would not recommend to use PM2, anywhere. You have been warned.

How to use a different ssh port for PM2

Since pm2-deploy directly forward the host string to ssh, you can simply use:

"host": "HOSTNAME -p PORT"

inside the configuration file.

How to use cluster_mode in PM2

Make your app instances listen on port 8000 and pm2 will load-balance any request on 8080 to your app instances.

{
"apps": [{
"name": "My app",
"script": "server.js",
"instances": 2,
"port": 8080,
"exec_mode": "cluster_mode"
}],
"deploy": {
"production": {
"user": "node",
"host": [{
"host": "my-host-name -p 22115",
}],
"ref": "origin/master",
"repo": "git@github.com:user/repo.git",
"path": "/app",
"post-deploy": "pm2 startOrRestart ecosystem.json --env production"
}
}
}
view raw ecosystem.json hosted with ❤ by GitHub

Troubleshooting pm2 deploy

pm2-deploy outputs its log into /tmp/pm2-deploy.log so if you don't understand why pm2 deploy is not working, a tail -f /tmp/pm2-deploy.log might help.

« »
 
 
Made with on a hot august night from an airplane the 19th of March 2017.