6

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.

user3094755
  • 1,561
  • 16
  • 20

4 Answers4

1

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

Sydney Y
  • 2,912
  • 3
  • 9
  • 15
1

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

Grandeto
  • 31
  • 4
0

Hi I fixed this by using an older version of pm2

npm uninstall -g pm2
npm install -g pm2@3.2.2
Arash Rabiee
  • 1,019
  • 2
  • 16
  • 31
-1

I just set -

 pm2_home=C:\Users\<Admin/Your Account>\.pm2

in environment variables.

And then

restart your the PC / server.

Techdive
  • 997
  • 3
  • 24
  • 49