Mailing List Archive

Restart Myth by remote control
Just thought I'd share a little idea I had. Since Mythfrontend still
has a seg fault every now and then, and since my wife doesn't understand
how to restart Mythfront end. I mapped one of my remote keys to a
script that restarts mythfrontend. The basic gist is this. I'm using
Xdialog (http://www.chez.com/godefroy/) to display a window that you can
select to restart or not, thus avoiding accidental restarts. If you
don't want to do this you can just ignore remove everything but the
killall and and mythfrontend commands.

Script looks like this:

#!/bin/sh

Xdialog --title "Restart Mythtv" --yesno "Would you like to restart
MythTV?" 0 0

if [ $? -eq 0 ]
then
sudo killall mythfrontend
mythfrontend &
fi

Save this and store it somewher in you path. I used /bin

Next add this to your lircrc:

begin
prog = irexec
button = tivo #Whatever Button you want to use
config = RestartMyth.sh
End

Finally, add irexec to whatever script you are using to start irxevent.

Now you have a restart key. Makes the Spousal Approval Level much
higher.
Re: Restart Myth by remote control [ In reply to ]
Why not have a script that runs mythfrontend in the foreground in a loop,
and whenever the process exits it checks the error code. Intentional exits
should give back 0, and crashes should give back nonzero, so the script
could automagically start mythfrontend again on nonzero results. Then
start the script in the background.

I guess another factor is that if you are using CVS and getting segfaults
it would be of more use to actually track these in hopes of debugging
them, rather than work around them as best as possible..

On Wed, 23 Apr 2003, ben wrote:

> Just thought I'd share a little idea I had. Since Mythfrontend still
> has a seg fault every now and then, and since my wife doesn't understand
> how to restart Mythfront end. I mapped one of my remote keys to a
> script that restarts mythfrontend. The basic gist is this. I'm using
> Xdialog (http://www.chez.com/godefroy/) to display a window that you can
> select to restart or not, thus avoiding accidental restarts. If you
> don't want to do this you can just ignore remove everything but the
> killall and and mythfrontend commands.
>
> Script looks like this:
>
> #!/bin/sh
>
> Xdialog --title "Restart Mythtv" --yesno "Would you like to restart
> MythTV?" 0 0
>
> if [ $? -eq 0 ]
> then
> sudo killall mythfrontend
> mythfrontend &
> fi
>
> Save this and store it somewher in you path. I used /bin
>
> Next add this to your lircrc:
>
> begin
> prog = irexec
> button = tivo #Whatever Button you want to use
> config = RestartMyth.sh
> End
>
> Finally, add irexec to whatever script you are using to start irxevent.
>
> Now you have a restart key. Makes the Spousal Approval Level much
> higher.
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@snowman.net
> http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-users
>
Re: Restart Myth by remote control [ In reply to ]
I handle my Myth process precisely as you describe, Dan. Although I am
not using CVS, I do get my share of segfaults. I just respawn a script
out of inittab (I run Myth in a custom runlevel 4) that restarts all my
myth services if Myth fails. I actually restart the whole GUI when myth
dies (or I kill it) but it could easily be modified to only loop around
myth. My only problem now is when myth freezes up, rather than
crashing. I will most likely have to implement a kill switch anyway :(
Here are my scripts:

In /etc/inittab (this technically does not need to be a respawn, but I
did it anyway just for kicks):
...
# MythTV respawns in runlevel 4
xm:4:respawn:/usr/local/bin/mythinit
...

/usr/local/bin/mythinit:

#!/bin/bash
export DISPLAY=localhost:0
SPAWNLIMIT=10
# We'll hang up in here, just for runlevel 4
x=0
while [ true ]; do
#Start X
/usr/X11R6/bin/X > /var/log/xout.log 2>&1 &
echo "X starting:PID $!"
sleep 5
/usr/X11R6/bin/blackbox &
echo "Blackbox starting:PID $!"
# Don't let screen blank
/usr/X11R6/bin/xset -dpms s off
## Start Myth
echo "Starting Myth"
/usr/local/bin/mythfrontend >> /var/log/myth.log 2>&1 &
MYTHPID=$!
echo "MythTV started, PID $MYTHPID"
echo "Starting Irxevent"
/etc/init.d/irx start
wait $MYTHPID
echo "MYTH DIED, RESTARTING ALL SERVICES"
/etc/init.d/irx stop
pkill blackbox
pkill X
# Wait for processes to exit before restarting
sleep 4
# Count the number of times we have done this, sleep if we
respawn too much
x=$(( $x + 1 ))
if [ $x -gt $SPAWNLIMIT ]; then
echo "ERROR: Myth respawing too much, disabling for 10
minutes"
sleep 600
x=0
fi
done


You could just run /usr/local/bin/mythfrontend out of inittab and it
will reliably stay up (barring freezes).


Dan Conti wrote:

>Why not have a script that runs mythfrontend in the foreground in a loop,
>and whenever the process exits it checks the error code. Intentional exits
>should give back 0, and crashes should give back nonzero, so the script
>could automagically start mythfrontend again on nonzero results. Then
>start the script in the background.
>
>I guess another factor is that if you are using CVS and getting segfaults
>it would be of more use to actually track these in hopes of debugging
>them, rather than work around them as best as possible..
>
>On Wed, 23 Apr 2003, ben wrote:
>
>
>
>>Just thought I'd share a little idea I had. Since Mythfrontend still
>>has a seg fault every now and then, and since my wife doesn't understand
>>how to restart Mythfront end. I mapped one of my remote keys to a
>>script that restarts mythfrontend. The basic gist is this. I'm using
>>Xdialog (http://www.chez.com/godefroy/) to display a window that you can
>>select to restart or not, thus avoiding accidental restarts. If you
>>don't want to do this you can just ignore remove everything but the
>>killall and and mythfrontend commands.
>>
>>Script looks like this:
>>
>>#!/bin/sh
>>
>>Xdialog --title "Restart Mythtv" --yesno "Would you like to restart
>>MythTV?" 0 0
>>
>>if [ $? -eq 0 ]
>>then
>> sudo killall mythfrontend
>> mythfrontend &
>>fi
>>
>>Save this and store it somewher in you path. I used /bin
>>
>>Next add this to your lircrc:
>>
>>begin
>> prog = irexec
>> button = tivo #Whatever Button you want to use
>> config = RestartMyth.sh
>>End
>>
>>Finally, add irexec to whatever script you are using to start irxevent.
>>
>>Now you have a restart key. Makes the Spousal Approval Level much
>>higher.
>>
>>_______________________________________________
>>mythtv-users mailing list
>>mythtv-users@snowman.net
>>http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-users
>>
>>
>>
>_______________________________________________
>mythtv-users mailing list
>mythtv-users@snowman.net
>http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-users
>
>
RE: Restart Myth by remote control [ In reply to ]
Well a couple of things. One of the reasons I took this route is that
myth freezes not just segfaults. This lets me get around that. I
always try to report segfaults, but I constantly run in debug and gdb.
It takes up to much processor. So while my wife is out on the weekends,
I recompile with debug and try to recreate any segfaults I've had over
the last week. If you look back through the archives probably half my
emails have the word bug attached to them.

Ben

-----Original Message-----
From: mythtv-users-bounces@snowman.net
[mailto:mythtv-users-bounces@snowman.net] On Behalf Of Dan Conti
Sent: Wednesday, April 23, 2003 12:33 AM
To: Discussion about mythtv
Subject: Re: [mythtv-users] Restart Myth by remote control


Why not have a script that runs mythfrontend in the foreground in a
loop, and whenever the process exits it checks the error code.
Intentional exits should give back 0, and crashes should give back
nonzero, so the script could automagically start mythfrontend again on
nonzero results. Then start the script in the background.

I guess another factor is that if you are using CVS and getting
segfaults it would be of more use to actually track these in hopes of
debugging them, rather than work around them as best as possible..

On Wed, 23 Apr 2003, ben wrote:

> Just thought I'd share a little idea I had. Since Mythfrontend still
> has a seg fault every now and then, and since my wife doesn't
> understand how to restart Mythfront end. I mapped one of my remote
> keys to a script that restarts mythfrontend. The basic gist is this.

> I'm using Xdialog (http://www.chez.com/godefroy/) to display a window
> that you can select to restart or not, thus avoiding accidental
> restarts. If you don't want to do this you can just ignore remove
> everything but the killall and and mythfrontend commands.
>
> Script looks like this:
>
> #!/bin/sh
>
> Xdialog --title "Restart Mythtv" --yesno "Would you like to restart
> MythTV?" 0 0
>
> if [ $? -eq 0 ]
> then
> sudo killall mythfrontend
> mythfrontend &
> fi
>
> Save this and store it somewher in you path. I used /bin
>
> Next add this to your lircrc:
>
> begin
> prog = irexec
> button = tivo #Whatever Button you want to use
> config = RestartMyth.sh
> End
>
> Finally, add irexec to whatever script you are using to start
> irxevent.
>
> Now you have a restart key. Makes the Spousal Approval Level much
> higher.
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@snowman.net
> http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-users
>
_______________________________________________
mythtv-users mailing list
mythtv-users@snowman.net
http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-users