Using PM2 with Shinobi
PM2 is a process manager that helps you start, stop, and auto-start Node.js scripts.
Before reading
Using PM2 should be done as a single user. The reason for this is that a new PM2 process to manage Node.js scripts is spawned for each user that runs PM2. I recommend running as root if you need to run shinobi on startup with PM2's builtin script.
If you know how to auto-start Shinobi without using root, like with a custom script, then you should do that.
This is important if you are getting errors stating that a port is already in use.
Starting and Stopping
First navigate to the Shinobi directory.
cd /home/Shinobi
Shinobi and the accompanying cron script can be started by doing the following.
pm2 start camera.js pm2 start cron.js
Shinobi can be stopped by running.
pm2 stop camera.js pm2 stop cron.js
Run Shinobi on Start-Up
Once Shinobi is started you can run the following to save it to startup. You must run pm2 as root to do this.
pm2 startup pm2 save
Check Shinobi Logs
You can either login to the Superuser panel or run the following to see logs about Shinobi itself.
pm2 logs