Using pcsk to Supervise mythbackend
If mythbackend has ever crashed on you, odds are that you didn't know and you missed out on recording a favourite programme. Here is a nifty rc script I wrote using the default /etc/init.d/mythtv-backend script in Ubuntu 7.04 (Feisty) as a base, but modified to have the following improvements:
1) The Process Creation's Swiss-Army Knife (PCSK) is used to supervise the mythbackend process and respawn it if it dies. Alternatives to pcsk include daemontools and psmon, but I like pcsk as it is small and simple and does exactly what I need. 2) The script is more clever about whether a process is actually running, rather than just checking for the existence of a .pid file (which will never work if the process crashed instead of being deliberately stopped) 3) You can simply run /etc/init.d/mythtv-backend start and know that no matter what the status was previously, mythbackend will be running afterwards (useful if another process or script is used to start mythbackend) 4) Non-root users stand a good chance of being able to determine the status of mythbackend without requiring sudo. 5) Additional status information is provided using Andrew Ruthven's mythtv-status perl script. This isn't mandatory, but is used if you have it installed.