Pm2: Document how to remove startup script

Created on 13 Jun 2015  Â·  12Comments  Â·  Source: Unitech/pm2

https://github.com/Unitech/pm2#startup-script-generation talks about generating startup script. What about removing the scripts for an app that's no longer needed?

Startup Enhancement Question

Most helpful comment

I found that deleting ~/Library/LaunchAgents/pm2.* will stop launching the daemon. The problem is that the plist is named pm2.username.plist but the script is trying to delete the file com.pm2.username.plist
https://github.com/Unitech/pm2/blob/f8a6a634623808625c9a0861553307268878944a/lib/API/Startup.js#L140

All 12 comments

:+1:
I tested it on my mac to make sure it works. Now I want to remove it and I have no idea how.

Agreed that this is absolutely needed. I want to use PM2 to run a service from an installer, and need to remove the script on uninstall. Documentation would be great, but a built-in command is even better.

i do need to remove my startup script in debian. how to do it with pm2?

On PM2 > 2.2.x:

$ pm2 unstartup

Not useful,
Problem presists.

When you install pm2 using apt-get install

And than uninstall using apt-get uninstall

the errors are shown on boot screen, because the scripts presists

and there is no pm2 on system already to run

pm2 unstartup

.....

Anybody got it working?
First I ran this.
pm2 unstartup
And got,
[PM2] Init System found: launchd
[PM2] You have to run this command as root. Execute the following command:
sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 unstartup launchd -u username --hp /Users/username

Then I run the command above and got undefined return code: 3.
[PM2] Init System found: launchd
undefinedReturn code : 3

Any help would be appreciated.

@chrisli30 I have started using pm2 very recently, and I have run into the same message trying to remove the startup script on my local Mac OS 10.12. My problem is that as soon as I ran the startup script and restarted the laptop, the memory usage stopped working. It seems that it fails to read the memory stats, but I haven't figured out the source of the problem yet. I could not find any relevant information online so I figured I would look at my config and system to try to pinpoint it more precisely before submitting a new issue on GitHub. It seems you are running pm2 on Mac OS as well. Have you observed any similar symptoms upon installing the startup script? Thanks!

Sorry, @kuzmicheff no I haven't dived much into memory usage feature, but mine seems to work fine on KeyMetrics which uses PM2. One thing to look at though is the same problem happen on another machine running Linux?

@chrisli30 My Amazon Linux server is running pm2 correctly; I was having the problem on my local MacBook. I cleaned up the system completely after uninstalling it earlier today, then reinstalled it, and restarted all apps. Now it is running correctly, but I have not run the startup script this time. I might need to file this behavior as a new issue, but I want to replicate it a few more times before I do. Thanks for your help!

I get the same errors as @chrisli30. Not sure what I might try to resolve them - anyone?

I got the same

➜  ~ pm2 unstartup
[PM2] Init System found: launchd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 unstartup launchd -u theara --hp /Users/theara
➜  ~ sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 unstartup launchd -u theara --hp /Users/theara
Password:
[PM2] Init System found: launchd


undefinedReturn code : 3

How to solve?

I found that deleting ~/Library/LaunchAgents/pm2.* will stop launching the daemon. The problem is that the plist is named pm2.username.plist but the script is trying to delete the file com.pm2.username.plist
https://github.com/Unitech/pm2/blob/f8a6a634623808625c9a0861553307268878944a/lib/API/Startup.js#L140

Was this page helpful?
0 / 5 - 0 ratings