Install and use Node Process Manager PM2

PM2 is an advanced process manager for for Node.JS application to keep an application running. In this article, we’ll discuss installation and various PM2 commands helpful in managing our Node.JS processes.

Install PM2:

  • PM2 can be installed using npm package manager, sudo npm install -g pm2.
  • To enable auto start at boot, pm2 startup and follow the on-screen instructions.
  • For more related PM2 commands, visit the Miscellaneous PM2 Commands section below.

Miscellaneous PM2 Commands:

  • Check status of all running process pm2 status.
  • Stop running PM2 at startup pm2 unstartup.
  • Check logs for a specific PM2 process pm2 logging 0. Where 0 is the id of first process. ID can be obtained using pm2 status command.
  • If PM2 processes do not load at startup, use pm2 resurrect command to bring them back.
  • Restart all processes at once pm2 restart all.
  • Removing a process from PM2 pm2 delete 0. Where 0 is the id of first process. ID can be obtained using pm2 status command.
1 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x