How to reset the id of pm2?
Asked Answered
C

3

21

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?

Counterpane answered 11/6, 2015 at 15:4 Comment(0)
C
21

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

Counterpane answered 12/6, 2015 at 2:41 Comment(0)
S
16

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
Steamroller answered 31/1, 2023 at 21:18 Comment(1)
I need to clean up the process id list (due to recent additional apps). This is exactly what I need. All process ID list now in sequence. It was not before due to issues getting the new app up to work. Great! Thank!Commendation
T
4

Per pm2's GitHub:

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

Reference: GitHub issue#1456

Tuscan answered 10/4, 2017 at 18:32 Comment(1)
The Question is about resetting the "id" counter, not the metadata of a process.Pandorapandour

© 2022 - 2024 — McMap. All rights reserved.