How to reset the id of pm2?

29.3k views Asked by At

I using pm2. After I started my app several times, the id increased. I deleted all in pm2, and started again, but the id didn't count from 0 any more. How can I reset it?

3

There are 3 answers

0
Yao Zhao On BEST ANSWER

The solution is to restart pm2, by typing pm2 kill as said by ItalyPaleAle in the comments.

1
nikhilweee On

Looking at the help menu (pm2 --help) it seems like pm2 reset would be the way to go. But that command resets metadata (restarted time, etc) and does not reset IDs. One solution is to use pm2 kill to kill the pm2 daemon and restart it again (thanks, @Yao Zhao). But doing so will stop all current processes. A better approach would be to save the list of current processes, restart pm2, and then restore those processes using the following set of commands.

$ pm2 save      # save current processes
$ pm2 kill      # kill pm2 daemon
$ pm2 resurrect # load saved processes
1
Ace On

Per pm2's GitHub:

$ pm2 reset <process>    # Reset meta data (restarted time...)

Reference: GitHub issue#1456