For my network, I’ve got two Mythtv machines. One is Saturn, the main recording backend. The other is Neptune, the supercharged media workhorse who has a frontend in addition to running my distributed DVD ripping, being part of a compile farm, holding all my music, and mysql databases.
Neither of the two are on a battery backup because I’m cheap, so when things go down, they don’t always come right back up. And sometimes Saturn’s mythbackend crashes. It happens.
So to prevent this, I added my mythtv-frontend user account to Saturn’s sudo list. Then I generated a ssh key and put it into the authorized_hosts file. Since all my accounts are managed with LDAP and /home is mounted over NFS, its really easy to syncronize both machines.
The final step is to change the ‘WOLBackendCommand’ setting in the database. The only sudo command mythtv-frontend can execute on Saturn is /etc/init.d/mythbackend restart. So I changed that setting to ssh saturn sudo /etc/init.d/mythbackend restart;sleep 5. The extra sleep allows for startup lag.
Now, if both machines go down, there isn’t a race condition between saturn waiting for neptune’s database to start before starting mythbackend. Once Neptune’s mythfrontend starts up it notices there isn’t a backend connection available. So it ssh’s into saturn, (re)starts the backend (It might be hanging, so thats why it restarts it), and waits politely for it to start.