This article is outdated and may not work correctly for current operating systems or software.
PM2 is a very popular Node process manager that makes running NodeJS applications easy. PM2 makes it easy to restart apps, automatically restart crashed applications and automatically start applications after a server reboot.
This article will teach you how to install PM2 and run basic setup on Ubuntu 16.04.
NPM- Learn to install here (ExpressJS is not strictly required)
This tutorial also assumes that you are logged in as
root. If you do not have access to the
root user, add
sudo to the start of all commands.
Installing PM2 is very simple, and can be done in a single line of code.
npm install -g pm2
Start by navigating to your project directory. You can do this by typing the
cd command followed by the directory.
To start your app, type the command
pm2 start followed by your app's location.
pm2 start /project/app.js
You will see a table that resembles the following image.
After running the code above, it is recommended that you setup PM2 as a service so that it can start when the server starts.
env PATH=$PATH:/usr/local/bin pm2 startup -u root
Make sure to replace
root with your username if you aren't using the