A Python script that automatically suspends the server, when it is not used, and another script to wake the server up again, in case there is work to do. To my surprise I could not find any out-of-the-box solution, so I thought, it is a worthwhile effort to write about it.
Currently, the server is primarily used for two things:
- Plex Media Streaming (remotely)
- Time Machine Backups (locally)
To monitor Plex activities, we access the local Plex API and for Time Machine we simply monitor any file access at /mnt using "lsof." In case there has been no activity for 15 consecutive minutes, the server goes to sleep. (Nobody streams, pausing a video doesn't count as activity, and no backup is running.) A Web server on a Raspberry Pi hosts a website that obtains the current state of the home server provided via the Home Assistant REST API. In case the server sleeps, and I like to backup or stream something, I can wake the server using a simple button press that sends a magic packet using a wakeonlan Perl script.
I've also heard of a trick of integrating WoL with DNS, where if the server requests a lookup for a local IP, it'd send WoL packets to the destination. You'd probably just need to set the TTL for the server's IP very low so that it doesn't get cached.
Currently, the server is primarily used for two things: - Plex Media Streaming (remotely) - Time Machine Backups (locally)
To monitor Plex activities, we access the local Plex API and for Time Machine we simply monitor any file access at /mnt using "lsof." In case there has been no activity for 15 consecutive minutes, the server goes to sleep. (Nobody streams, pausing a video doesn't count as activity, and no backup is running.) A Web server on a Raspberry Pi hosts a website that obtains the current state of the home server provided via the Home Assistant REST API. In case the server sleeps, and I like to backup or stream something, I can wake the server using a simple button press that sends a magic packet using a wakeonlan Perl script.
GitHub: https://github.com/m33x/wol-plex-server