PM2 deleted process runs on startup
Asked Answered
E

2

18

I have a pm2 process named app that was used to test the configuration.

I noticed app was starting when the system rebooted, and it was causing errors with the real application.

I ran:

 pm2 delete app

then I ran:

 pm2 list

and it didn't show app.

When I reboot my system, the app is still there and it is running. I attempted to find information on where the config file is online, and there is no information other than creating a template config file. Where should the config file that pm2 reads on startup be located on an Ubuntu system, or why isn't delete working as I intend? Is there another method or command I can use to remove a pm2 process or am I looking at this incorrectly?

Execration answered 6/10, 2018 at 21:11 Comment(0)
H
45

If you use "pm2 delete {appname}" to delete the last app

pm2 delete app

when you run

pm2 save

It will show

[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 !

Which means, actually, the last app information is still not deleted.

The solution is to create a new dump file.

pm2 cleardump

Then, the app will be deleted permanently.

You can check the pm2 file to see what's actually saved into dump file.

/home/ubuntu/.pm2/dump.pm2
Henghold answered 9/2, 2019 at 21:56 Comment(3)
about using pm2 save --force?Excipient
I haven't tried option --force, but based on pm2.keymetrics.io/docs/usage/application-declaration, seem "--force" is for starting a process. I will try and update here. Thanks.Henghold
--force option works! pm2 save --force [PM2] Saving current process list... [PM2] Successfully saved in /root/.pm2/dump.pm2Backfire
E
6

Saving some time for those who may or may not use pm2 regularly and struggle when searching for an answer on this:

You have to save the edits for pm2:

pm2 save

after making any changes. Unlike most Unix style settings interfaces, pm2 requires you to save your changes from the running version to the config file.

Hope this helps someone even though it is simple! I don't use PM2 all the time and it was really frustrating to not find any answers on SO or anywhere else that referred to the need to use pm2 save when deleting a process.

Execration answered 6/10, 2018 at 21:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.