I just installed CentOS 8 and added nodejs (tried v12 & v14) And then I installed pm2 using npm install pm2@latest (so at the time of posting it uses v4.4.0). I did try an older version (v3.5.0), but it does the exact same thing.
and after pm2 got installed, i ran the command "pm2 startup"
after a restart, pm2 does start, but gets killed after 90 seconds and then restarts giving this message
"pm2 has been killed by signal, dumping process list before exit…"
First, I thought it was because of my app (the one that pm2 is supposed to manage), but i removed it from pm2, so it’s practically empty, but it does the same thing
5
Answers
Later update. For those who are facing the same issues. It's an issue related to SE Linux. Known workarounds (the ones I discovered).
Disabling SE Linux (obviously, not recommended)
go to /etc/systemd/system/pm2-root.service - comment PIDFile=... (add a # in front of that line)
Audit and trace - use following commands:
At ths point, you should see the solution in the output (the log) it should be something like:
You need to do the last step (ausearch... and semodule...) twice - I did it once, restarted the machine and noticed the same issue after 90 seconds. But if you read the log carefully, you will notice that the issue seems to be outputed twice. (looks the same). Probably two things are trying to write to that file (pm2-root.service).
Still waiting for the perfect solution (done by the person that really knows how to fix this in a proper manner), but for those that have this issue, any of these options seem to work just fine.
I had the same issue and I tried several solutions online but none worked for me.
However, I completely removed
pm2
, restarted the server, and reinstalledpm2
and that does it for me.1- Stop and remove
pm2
2- Restart the server
3- Log in again, then reinstall pm2
I’ve had this problem (on Debian), when for some reason two "PM2 God Daemon" processes (not threads) were launched, so they conflicting with each other.
Killing one of them solved the issue.
I did not disable SE Linux (I think it’s not safe to disable it), but the following method helped me:
Edit file: /etc/systemd/system/pm2-root.service
Add new line:
Environment=PM2_PID_FILE_PATH=/run/pm2.pid
And replace:
PIDFile=/root/.pm2/pm2.pid
to:PIDFile=/run/pm2.pid
Versions:
Original answer. Thanks Alec!
Running the following command as root worked for me: