Click here to Skip to main content
15,889,406 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm working in Centos 7, trying to get a node.js app to automatically start at boot.

I'm using PM2 for this, and all seems fine until I reboot the server, at which point the dump.pm2 file is overwritten and is blank.

Any ideas?

What I have tried:

I can 'pm2 delete process' and 'pm2 resurrect' to my heart's content while the system's up, but if I restart the server it fails.

As a test, I made a copy of the dump.pm2 file and rebooted the server. the dump.pm2 file was empty after reboot, but I restored my backup copy after which the 'pm2 resurrect' command successfully started my application list.
Posted
Updated 27-Apr-16 8:42am

It would appear that there is a bug in the current pm2 implementation.

The bug appears when you try to run pm2 in a non root account. Somehow, during boot and while pm2 is loading, it appears to be examining the incorrect folder for the existence of a dump.pm2 file (which holds the desired application list and parameters). When it doesn't find the file, it makes note that it needs to create one. Later, after switching into the appropriate user account, it then writes a blank dump.pm2 file which overwrites the previously created one.

This GitHub submission identifies the issue:

https://github.com/Unitech/PM2/pull/1120/files?diff=split

You can also temporarily remedy the issue by making making the dump.pm2 file immutable after you save your desired startup application list

i.e.

C++
pm2 save                        // store current running application list to dump.pm2
su                              // switch to root account
cd /home/{pm2useraccount}/.pm2  // move to .pm2 folder for user in which pm2 is running
chattr +i dump.pm2              // mark dump.pm2 file as immutable.
 
Share this answer
 
v3
I had the same issue on a Raspberry Pi running Debian. Please look at the following solution:

Startup is not starting pm2 daemon and saved process · Issue #1055 · Unitech/pm2 · GitHub[^]

It seems that you will need to comment the following line:

Java
#super $PM2 dump


This line is located in the stop() function inside the /etc/init.d/pm2-init.sh file.

Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900