Pm2 process stops running

13,332

Solution 1

This is most likely an indication that your server is rebooting. When your server reboots, PM2 shuts down and deletes all Node instances from its "status" list.

You can perform the following steps to make PM2 relaunch your Node programs start back up on reboot:

  1. Run pm2 startup and follow the directions (you will have to perform a sudo command; PM will tell you exactly what to do).
  2. Through pm2 start, get your Node processes up and running just like you like them.
  3. Run pm2 save to register the current state of things as what you want to see on system startup.

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

Solution 2

Did you try checking logs $ pm2 logs for you application?

Most likely it will tell you why your application was terminated or maybe it just exited as it supposed to. You could find something like that there:

PM2 | App [app] with id [0] and pid [11982], exited with code [1] via signal [SIGINT]

This can tell you what happened. Without more details, it's hard to give you a better answer.

Share:
13,332

Related videos on Youtube

Johan
Author by

Johan

Updated on June 04, 2022

Comments

  • Johan
    Johan over 1 year

    I have a node chat application that needs to keep running on my server (ubuntu with nginx). The problem is that the application stops after a few hours or days. When I check on the server I see that my pm2 list is empty.

    The code I use to start my app:

    pm2 start notification_server/index.js
    

    It somehow looks as if pm2 is reset after a while. I also tried using forever, but then I run into the same problem. Is there some way to prevent the pm2 list from getting empty?