diff --git a/nodeJS/PM2.md b/nodeJS/PM2.md new file mode 100644 index 0000000..f7130f1 --- /dev/null +++ b/nodeJS/PM2.md @@ -0,0 +1,73 @@ +# PM2 Quick Start + +* Process Manager for Deployment of node js app +* [Reference](https://pm2.keymetrics.io/docs/usage/quick-start/) +* ![](./pm2-deploy.PNG) + + + +```sh +# install pm2 +$ npm i pm2@latest -g + +# serve static site created by react +# pm2 serve --spa +$ pm2 serve build 8082 --spa + +# to serve web app using "ecosystem.config.js" +# serve at port 3001 (configured in index.js) +$ pm2 start ecosystem.config.js + +# start app as daemon +$ pm2 start server.js --name "wallet-api" + +$ pm2 list + +# stop process and start again +$ pm2 restart + +# start new process, after started, stop old process +$ pm2 reload + +$ pm2 logs + +$ pm2 stop + +$ pm2 delete all + +# terminal based monitoring dashboard +$ pm2 monit +``` + + + +* [Ecosystem](https://pm2.keymetrics.io/docs/usage/application-declaration/) + +* [vuejs deployment](https://medium.com/@kamerk22/deploy-vue-js-ssr-vuetify-on-production-with-pm2-and-nginx-ec7b5c0748a3) + +* To generate `ecosystem.config.js` + + ```sh + $ pm2 ecosystem + ``` + + + +* `ecosystem.config.js` generated using above command + +```json +module.exports = { + apps: [ + { + name: 'web-apps', + script: './app-server/index.js', + watch: true, + env: { + NODE_ENV: 'production', + }, + }, + ], +}; + +``` + diff --git a/nodeJS/pm2-deploy.PNG b/nodeJS/pm2-deploy.PNG new file mode 100644 index 0000000..0e2db95 Binary files /dev/null and b/nodeJS/pm2-deploy.PNG differ