PM2 – startup script for node.js

[step 1] Generating a PM2 startup script

pm2 startup

To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u agink –hp /var/www/

[step 2] Saving all running PM2 processes

pm2 save

If you ever need to reboot all processes manually, you can also execute the following command

pm2 resurrect

— other —

$ pm2 startup # Detect init system, generate and configure pm2 boot on startup
$ pm2 save # Save current process list
$ pm2 resurrect # Restore previously saved processes
$ pm2 unstartup # Disable and remove startup system