Member-only story

How to deploy with pm2 Javascript applications — boobo94

Bogdan Alexandru Militaru
2 min readFeb 14, 2020

Today I talk with you about how to deploy with pm2. I want to present a simple example for a node.js app, but you can use it to deploy react, Vue or other Javascript apps.

I know how frustrating is for some of you this part about devops. That’s why pm2 comes throw us like an angel which wants to save the humanity in front of Continous Deployment process.

Pm2 configuration file

{
"apps": [{
"name": "App",
"script": "./app.js",

"autorestart": true,
"watch": false,
"max_memory_restart": "1G",
"env": {
"NODE_ENV": "development",
},
"env_production": {
"NODE_ENV": "production",
}
}],

"deploy": {
"development": {
"user": "user",
"host": "111.111.111.111",
"ref": "origin/develop",
"repo": "git clone git@github.com:repo.git",
"path": "/var/www/development",
"post-deploy": "cd /var/www/development && npm install && pm2 reload ecosystem.json"
},
"production": {
"user": "user",
"host": "222.222.222.222",
"ref": "origin/develop",
"repo": "git clone git@github.com:repo.git",
"path": "/var/www/production",
"post-deploy": "cd /var/www/production && npm install && pm2 reload ecosystem.json --env production"
}
}
}

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response