Search code examples
node.jspm2

PM2 - Current process list is not synchronized with saved list


I have a windows server where I have some code running. I am using pm2 to manage 2 processes on this server. Everything was working fine until a few weeks ago where I had a user rollback the server due to some issues. The user also had to restart the pm2 processes. Since then I am not able to find the running pm2 processes anymore though I do know they are running as the application running off these pm2 processes is still working.

When I type in pm2 ls to see what the processes running are I get the following warning:

[PM2][WARN] Current process list is not synchronized with saved list. App sampleprocess1 sampleprocess2 differs. Type 'pm2 save' to synchronize.

When I type in pm2 save to synchronize I get the following warnings:

[PM2] Saving current process list...
[PM2][WARN] PM2 is not managing any process, skipping save...
[PM2][WARN] To force saving use: pm2 save --force

How can I navigate around this as I need to make some changes to the codebase and will eventually need to restart the pm2 processes running?


Solution

  • Running pm2 save with empty process list would erase your saved processes, fortunately pm2 prevents you from doing that.

    To manually bring back previously saved processes (via pm2 save):

    pm2 resurrect
    

    ...that will restore your processes. Then I recommend running:

    pm2 save
    pm2 startup
    

    Then copy and run the command that "pm2 startup" shows you.

    Source: https://pm2.keymetrics.io/docs/usage/startup/

    Now processes will automatically start on system reboot & startup.

    Note: it seems 'pm2 startup' is only for linux. For a windows alternative, check the link above