Created
March 22, 2019 05:45
-
-
Save JP1016/f74cfceaf281bcd6b9e52504db4037f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I ran into this issue, and found a solution that works for me. Let's assume I've created a user named 'node' to run pm2. All of the commands below should be run by the node user, in the node user's home directory (/home/node) | |
Clear any pm2 dump files, and then start the appropriate services | |
% pm2 delete all | |
% pm2 dump | |
% pm2 start app.js --watch | |
Save the current config to start on reboot | |
% pm2 save | |
% sudo pm2 startup centos -u node | |
Edit the PM2_HOME path in the pm2-init script to match the home directory of the user: | |
% sudo vi /etc/init.d/pm2-init.sh | |
export PM2_HOME="/home/node/.pm2" | |
I found the issue was, the user was being set appropriately in the pm2-init.sh file, but the PM2_HOME directory was set to /root/.pm2 by default | |
==UPDATE== | |
For centos, I was able to replace step 2 above with the following: | |
% sudo su -c "env PATH=$PATH:/usr/local/bin PM2_HOME=/home/node/.pm2 pm2 startup centos -u node" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment