I experimenting with pm2, which is a process manager for node.js applications. I tried their pm2 startup utility which generates and installs a startup script for pm2 when the system restarts.
I tried this on my mac, and it works flawlessly. The pm2 automatically restarts and spawns up all my node scripts.
However now, I am done experimenting and how do I remove this from my startup? I wish pm2 came with a similarly simple utility to uninstall itself from startup.
I am aware that it is using launchd
on mac to restart the process. I noticed that it installed a io.keymetrics.PM2.plist
file under /Users/<username>/Library/LaunchAgents
directory.
Is it as simple as just deleting this file? or is it doing something more intrusive , and needs a more graceful uninstall?
It internally uses the following command to install the startup script
sudo env PATH=$PATH:/usr/local/bin pm2 startup darwin -u shaunak
First, get a list of all running agents using:
launchctl list | more
Or, if pm2 agent goes by the same name:
launchctl list | grep pm2
Then once you have the name of the pm2 agent that is part of launchd, execute:
sudo launchctl remove <pm2-agent-name>
And that's it. If you want to include an agent in the future again, you can do it by:
sudo launchctl load <agent-name>
Use launchctl unload.
launchctl -w unload ~/Library/LaunchAgents/io.keymetrics.PM2.plist