I am using pm2 to start a node.js process, and I would like this process to be started automatically when the system (Ubuntu 14.04 on Intel Atom processor) is booted. I have followed the instructions on the pm2 web site but without success. My dump.pm2 appears to be correct, but the pm2 daemon is never started. I have tried both the ubuntu
and linux
options to pm2 startup
, as well as autodetect, both with and without a specified user. Files (links) S20pm2-init.sh
have been created in /etc/rc[2-5].d
but nothing gets started. I can't find find any obvious error messages in the system log.
Any ideas?
Edit to add
I find that
service pm2-init.sh start
starts the daemon correctly, when run from my login account, which is the same as that defined by USER=
in the file /etc/init.d/pm2-init.sh
. I've made sure the PM2_HOME
definition in this file points to the correct place as well. However, it still doesn't start on system boot!
For pm2 startup to work, there's a critical command buried in documentation and here.
You have to 1) start all your processes, 2) create the startup script, and 3) run
pm2 save
Reference to @lazlojuly's answer here.