Install PM2 for Jekyll

Install PM2 for Jekyll

by John Vincent


Posted on March 1, 2017


This is part of a series of discussions regarding Deploying to a Digital Ocean Droplet. For more details, please see Overview of johnvincent.io website

Install PM2 for Jekyll

See PM2 Overview for details.

Start Ghost in Production

cd /var/www/ghost
NODE_ENV=production pm2 start index.js --name ghost

verify is running:

https://ghost.johnvincent.io

Start Ghost - local server

cd /var/www/ghost
pm2 start index.js

Change Ghost Blog

If make a change to your blog, you must restart:

pm2 restart all

Useful PM2 commands

pm2 list

pm2 stop <process-id>
or:
pm2 stop all

pm2 restart <process-id>
or:
pm2 restart all

pm2 delete <process-id>

pm2 describe <process-id>

pm2 monit

pm2 logs APP-NAME

pm2 flush

pm2 reloadLogs

PM2 Logs

~/.pm2/logs

Start Ghost on System Startup

PM2 will restart processes if they crash but cannot start itself.

Thus, need to start PM2 on system boot.

Useful reference

To get the automatically-configured startup script:

pm2 startup
[PM2] Init System found: systemd
[PM2] You have to run this command as root. Execute the following command:
sudo env PATH=$PATH:/usr/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u jv --hp /home/jv

+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save

[PM2] Remove init script via:
$ pm2 unstartup systemd

Execute the suggested command:

sudo env PATH=$PATH:/usr/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u jv --hp /home/jv

Check status of systemd unit:

systemctl status pm2