Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PM2 keeps getting killed every 90 seconds on centos 8

Tags:

pm2

centos8

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

like image 801
Alex Laz Avatar asked Jul 09 '20 12:07

Alex Laz


2 Answers

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
like image 110
Shakirah Avatar answered Oct 04 '22 02:10

Shakirah


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!

like image 31
Epexa Avatar answered Oct 04 '22 04:10

Epexa