[mythtv-users] Script to restart backend after crash?

Piers Kittel mailing at biased.org
Fri Jan 18 15:25:17 UTC 2008

Hi all,

Having a small problem with my backend - lately, it seg faults quite  
often (once or twice a week).  I don't have time to deal with that  
right now, but my pressing concern is that when the backend crashes,  
it doesn't start up again, causing some shows not being recorded  
causing the WAF of MythTV to go down by a large amount (some shows my  
girlfriend loves has failed to record lately, so she's not too  
impressed, she even mentioned buying a PVR...).

So I need some sort of script to monitor the backend and restart it  
automatically when it stops working for some reason.  Does anyone have  
some?  The package I use is from debian-multimedia.org, currently  
version 0.20.2-0.2.  It does come with its own startup script but  
doesn't work for some reason:

destiny:/home/piers# /etc/init.d/mythtv-backend start
mythbackend already running, use restart instead.
destiny:/home/piers# ps aux | grep myth
root     17771  0.0  0.1   2848   704 pts/1    R+   15:18   0:00 grep  
destiny:/home/piers# /etc/init.d/mythtv-backend restart
Restarting MythTV server: mythbackend No /usr/bin/mythbackend found  
running; none killed.
destiny:/home/piers# ps aux | grep myth
root     18079  0.0  0.1   2848   700 pts/1    R+   15:20   0:00 grep  
destiny:/home/piers# /etc/init.d/mythtv-backend stop
Stopping MythTV server: mythbackend No /usr/bin/mythbackend found  
running; none killed.
destiny:/home/piers# /etc/init.d/mythtv-backend start
Starting MythTV server: mythbackend .
destiny:/home/piers# ps aux | grep myth
root     18096  0.0  0.1   2844   704 pts/1    S+   15:20   0:00 grep  

Looking into the logs, I get:

2008-01-18 15:22:43.551 Using runtime prefix = /usr
2008-01-18 15:22:43.658 New DB connection, total: 1
2008-01-18 15:22:43.680 Unable to connect to database!
2008-01-18 15:22:43.681 Driver error was [1/1045]:
QMYSQL3: Unable to connect
Database error was:
Access denied for user 'mythtv'@'localhost' (using password: YES)

QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
2008-01-18 15:22:43.738 DB Error (KickDatabase):
Query was:
No error type from QSqlError?  Strange...
2008-01-18 15:22:43.790 Failed to init MythContext, exiting.

This isn't too important as the startup script don't automatically  
restart MythTV anyway.  So I just start a screen session and start the  
backend there, which works fine.  Obviously this means I have to start  
the backend manually when the computer boots up and restart it  
manually if it crashes.

Does anyone have a script that automatically restarts the backend or  
should I be fixing something else first?

Thanks very much for your time in advance!

Regards - Piers

More information about the mythtv-users mailing list