Monday | 15 APR 2024
[ previous ]
[ next ]

Using PM2

Date: 2022-11-13

A very useful process manager utility. This utility will handle making sure node applications stay up.

First step is to install pm2 globally.

npm install -g pm2

The second step is to start a project:

pm2 start bin/www --name project-name

This will start the project with a name. Now pm2 will make sure the project stays up.

pm2 startup

This will enable everything that pm2 is managing to start on boot. This will create a systemd init file which is quite handy.

You can also list out processes:

pm2 list

Finally, if you add need projects you can run, once you start them you can then save the currently running list again:

pm2 save