Also related to #3626
The following commands brings back all the processes because pm2 save ignores saving empty process state.
$ pm2 delete all
...
$ pm2 save
[PM2] Saving current process list...
[PM2] Nothing to save !!!
[PM2] In this case we keep old dump file. To clear dump file you can delete it manually !
$ pm2 update
...
So to my understanding, cleaning the process state is not possible with just pm2 commands? If that's the case, it's a bit surprising to me, I thought it would be one of the common operations that users need.
I just found pm2 cleardump command. Closing the issue.
Though I think the error message can be better, maybe mentioning pm2 cleardump directly.
I would not consider that issue as closed.
My issue is that I am programmatically adding or removing processes, afterwards executing pm2 save. However when the number of processes gets to zero this just breaks and the last process that was in the list will be started on next boot even though it shouldn't be.
That's a serious concearn. I consider that bad behaviour of the save/dump function. Please make it accept empty process lists!
@StT191 Why don't you call pm2 cleardump command and then pm2 save ?
That way, the dump does not exist, if the process list is empty and when it's not empty, it's saved as usual ...
But still, there could be a parameter like -f (to force-save even if the process list is empty).
Once introduced, the current functionality is kept, if someone depends on it.
Well, that's a feasible solution! You may close the issue then after all.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@StT191 Why don't you call
pm2 cleardumpcommand and thenpm2 save?That way, the dump does not exist, if the process list is empty and when it's not empty, it's saved as usual ...
But still, there could be a parameter like -f (to force-save even if the process list is empty).
Once introduced, the current functionality is kept, if someone depends on it.