I have several pieces of server software installed on my MacBook Pro for work using Homebrew. There is one service in particular, that likes to peg the CPU after the OS wakes up from sleep until I restart it. The service is currently managed by launchd, and I am wondering if there is a way for me to tell launchd to stop the service when the OS goes to sleep, and then start it up again on wake.
Way to make launchd stop a service on sleep and start it up again on wake
launchdsleep-wake
Related Question
- Sleep-Wake – Addressing Aggressive Mountain Lion Sleep Issues in Power Management
- Mac – External hard disc not ejected properly
- PostgreSQL – Use with launchd Without Issues
- MacOS – Why “wake for network access” does not work when setting CI server
- MacOS – How to Stop a Launchd Script from Running on Wake
Best Answer
You can use SleepWatcher:
Run
launchctl load <path>
andlaunchctl unload <path>
with SleepWatcher on wake and sleep respectively.