PM2

nodejs-deployment

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-centos-7

What is PM2?

PM2 is a process manager for Node application. See its web site for the full list of feature.

  1. Applications that are running under PM2 will be restarted automatically if the application crashes or is killed

How can we install PM2?

npm install pm2

How can we start our application using PM2?

pm2 start app.js

What is the purpose of the startup command?

The startup subcommand generates and configures a startup script to launch PM2 and its managed processes on server boots. You must also specify the init system you are running on, which is systemd, in our case:

sudo pm2 startup systemd

How can we stop our application?

pm2 stop example

How can we restart our application?

pm2 restart applicationName

How can we display the list of applications that are currently being managed by PM2?

pm2 list

What are other commands?

pm2 info applicationName
pm2 monit
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License