PM2 resurrect not working on reboot - dump.pm2 being emptied
Asked Answered
P

1

6

I'm trying to configure PM2 to daemonize a simple node.js server on centos. The init.d script executes, and there are no errors, but pm2 list returns an empty list, and the server is not starting.

Originally, I was attempting to start the process as a different user (for those interested, this can be done with modifications to pm2-init.sh). But due to the complication, I decided to first try to get it to run as root.

The strange symptom of the problem is that the dump.pm2 file is being emptied by some process, thus the pm2 resurrect has nothing to do. I set up pm2 to run on reboot as follows

$ pm2 startup centos
$ pm2 start /path/to/my/server.js
$ pm2 save

At this point, dump.pm2 had a large JSON object in it and the server is running. Then, running:

$ reboot
  ... wait and log back in
$ pm2 list

It was empty again, and so was the dump.pm2!

I'm not sure what process is clearing this file. I've tried reinstalling and re-running the startup script to no avail. Any help is greatly appreciated.

Paperboy answered 15/4, 2015 at 14:39 Comment(0)
P
4

As a temporary workaround, I set the dump file as immutable:

$ chattr +i /path/to/my/dump.pm2

This worked. Although not ideal, it is what I will use until I can determine why the dump.pm2 file is being emptied.

Paperboy answered 15/4, 2015 at 14:39 Comment(5)
Hey @Jamie Counsell let me know if you had any progress in this! I am also using your temporary workaroundBumgardner
Unfortunately, still no progress. I dug around in the source code to look for the cause, but I'm not sure if it's an issue with PM2, FS, or something else. It's also hard to track exactly when the file is touched (though I'm sure there is a way). Are you on Centos as well? It might be worth it to open an issue on Github.Paperboy
I am using Raspian (debian optimized for the Raspberry Pi)! I will try a little more and I'll let you know if I get to a solution, otherwise opening a Issue might be appropriate!Bumgardner
This approach filled my logfiles with EACCESS errors, so I decided to utilize monit and pm2 together. dev.iachieved.it/iachievedit/using-monit-with-node-js-and-pm2Breastbeating
same here. From time to time suddenly my ~/.pm2/dump.pm2 becomes empty. Happened already a few timesFenella

© 2022 - 2024 — McMap. All rights reserved.