13

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

Alex Laz
  • 339
  • 2
  • 6
  • I'm seeing the same thing on RHEL 8.2, node v12.16.1. Every 90 seconds `pm2 has been killed by signal, dumping process list before exit...` Have you found any solution? I don't see anything useful in my logs. I have the same versions and setup running in another environment, but I don't see the issue there. But every 90 seconds, restart. – baronnoraz Jul 17 '20 at 20:11
  • I have a similar issue. It isn't always 90 seconds, sometimes it is 60 seconds and sometimes 120 seconds. I did find that pm2 tests for memory usage every 30 seconds which seems to be related but haven't found anything yet. – Jedediah Smith Jul 20 '20 at 22:04
  • Have you found anything? The same is happening for me, exactly 90 seconds every time. Whether I'm just running one API or multiple, the whole pm2 process gets restarted.. – peterdotplus Jul 27 '20 at 14:36
  • Yes, please read below (3 options). Use either the second or the third for now. – Alex Laz Aug 02 '20 at 00:13

5 Answers5

13

Running the following command as root worked for me:

pm2 update
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Roman
  • 167
  • 2
  • 9
  • Could you provide more details on what this command does? – Tyler2P Nov 04 '21 at 16:42
  • It updates pm2 itself. – Roman Nov 08 '21 at 17:16
  • I didn't use sudo and it worked for me (Oracle Linux 8). However, I'm wondering if this needs to be run each time the server restarts and the service begins. Has anybody encountered that behavior or was it just fixed for good at that point? – cwadrupldijjit Apr 28 '22 at 21:33
9

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 reinstalled pm2 and that does it for me.

1- Stop and remove pm2

pm2 kill
sudo npm remove pm2 -g

2- Restart the server

sudo reboot

3- Log in again, then reinstall pm2

sudo npm install -g pm2
Hello World
  • 2,673
  • 7
  • 28
  • 60
Shakirah
  • 197
  • 1
  • 4
9

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

  1. Add new line: Environment=PM2_PID_FILE_PATH=/run/pm2.pid

  2. And replace: PIDFile=/root/.pm2/pm2.pid to: PIDFile=/run/pm2.pid

Versions:

  • CentOS 8.3.2011
  • Node.js 14.16.0
  • NPM 7.7.5
  • PM2 4.5.5

Original answer. Thanks Alec!

Epexa
  • 265
  • 2
  • 8
7

Later update. For those who are facing the same issues. It's an issue related to SE Linux. Known workarounds (the ones I discovered).

  1. Disabling SE Linux (obviously, not recommended)

  2. go to /etc/systemd/system/pm2-root.service - comment PIDFile=... (add a # in front of that line)

  3. Audit and trace - use following commands:

     # dnf install policycoreutils-python-utils setroubleshoot-server -y
     # journalctl -f
    

    At ths point, you should see the solution in the output (the log) it should be something like:

    # ausearch -c 'systemd' --raw | audit2allow -M my-systemd
    # semodule -i my-systemd.pp
    

    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.

Alex Laz
  • 339
  • 2
  • 6
0

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.

mortiy
  • 669
  • 7
  • 9