Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Message Spawning PM2 daemon with pm2_home=<home_dir>/.pm2 always

Tags:

amazon-ec2

pm2

On ec-2 instance whenever I execute pm2 I get the message...

Spawning PM2 daemon with pm2_home=<home_dir>/.pm2

This occurs with pm2 info, pm2 list, pm2 -h etc.

A bare pm2 will show help.

I can get more response from sudo -i.

It seems something is stopping PM2 from demonising when non-sudo.

like image 701
user3094755 Avatar asked May 04 '17 14:05

user3094755


2 Answers

This solved the problem in my case:

pm2 delete 0

I had been looking at other answers like reinstalling pm2, installing a previous version, permission issues, and none of them worked or applied to my case.

I'm not positive but I think I had a buggy process that was blocking the spawn. I had used pm2 a couple of days prior when I first logged into my server but I had been running an app that kept crashing and I tried to listen on port 80 and got permission errors. Ubuntu 18 server machine, Node 12.14.1, NPM 6.13.4, PM2 4.2.3

like image 137
Sydney Y Avatar answered Nov 09 '22 01:11

Sydney Y


This usually means that pm2 is running under PID that differs from the one in your .pm2/pm2.pid

To exit from this situation try one of these:

pm2 kill

or

ps aux | grep pm2 and then kill -9 PID found in PM2 vX.X.X: God Daemon

if none of the above help:

pkill node && \
pm2 delete all && \
pm2 flush && \
kill -9 $(head -n 1 /home/$USER/.pm2/pm2.pid) && \
rm -rf /home/$USER/.pm2

After that run pm2 ls or whatever pm2 command you want. That should daemonize pm2 again with the correct PID in .pm2/pm2.pid

EDIT

Another possible reason could be any error during the pm2 init, so if the above doesn't work for you check .pm2/pm2.log for any errors and fix them

like image 1
Grandeto Avatar answered Nov 09 '22 02:11

Grandeto