PM2 is a process manager for the JavaScript runtime Node.js
PM2 is similar to systemctl if you are familiar with linux system, this tutorial is for ubuntu.
To install , please run
yarn global add pm2
if you do not have yarn, run
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
Run PM2 in dev mode
pm2-dev start app.js
Run PM2 in production
pm2 start app.js
Manage Node app with name sample_app using PM2 as process.
pm2 start yarn --name "sample_app" --interpreter bash -- start
pm2 show sample_app
Restart sample_app
pm2 restart sample_app
Stop sample_app
pm2 stop sample_app
Delete sample_app
pm2 delete sample_app
Run pm2 on startup
pm2 startup
PM2 real time monitoring
pm2 monit
list apps managed by PM2
pm2 list