[mythtv-users] Start Mythfrontend if not running?
nate s
nate.strickland at gmail.com
Sat Dec 18 00:54:08 UTC 2004
You can pretty much add however scripting magic you want to , for
whatever your needs (logging, for example,) but basically, what you
need is something like
while true
do mythfrontend
done
You'll have to either alt-tab to the term you ran that in and do ^C or
kill it to exit mythfrontend.
-Nate
On Fri, 17 Dec 2004 12:36:39 -0500, Kyle Rose <krose+mythtv at krose.org> wrote:
> Here's another approach. Since I never stop the frontend in my living
> room except to reboot it (which I generally do via SSH), I use a
> script I hacked up to somewhat intelligently control a program that
> crashes at startup (mainly due to transient errors):
>
> krose_run
> ---------
> #! /bin/bash
>
> # === CONFIG START ========================
> BLIPCYCLE=30
> ROLLDELAY=900
> # === CONFIG END ==========================
>
> trap finalize 15
>
> finalize()
> {
> if [ "${CHILDPID}" != "" ]; then
> kill ${CHILDPID}
> fi
> exit 0
> }
>
> LASTSTART=0
> while true; do
> NOW=`date +%s`
> TOOSHORT=$((${NOW}-${LASTSTART} < ${BLIPCYCLE}))
> if [ ${TOOSHORT} = 1 ]; then
> sleep ${ROLLDELAY} &
> CHILDPID=$!
> wait ${CHILDPID}
> CHILDPID=""
> fi
> LASTSTART=`date +%s`
> "$@" &
> CHILDPID=$!
> wait ${CHILDPID}
> CHILDPID=""
> done
> ---------
>
> You then can run any command that should run forever (i.e., until
> the krose_run instance is TERM'ed) just by prepending it with
> krose_run:
>
> krose_run /usr/local/bin/mythfrontend --verbose playback
>
> and the program will be continually respawned until TERM'ed, but will
> wait 900 seconds before the next attempt if the program exits less
> than 30 seconds since the last execution.
>
> I use this to run both my backend and frontend: the backend init
> script calls krose_run on /usr/local/bin/mythbackend directly, while
> the frontend init script calls startx as user mythtv for "start" and
> for "stop" relies on a pid file that .xinitrc writes for the krose_run
> process that manages mythfrontend. This way, both backend and
> frontend keep respawning until I explicitly stop them with the init
> script.
>
> Cheers,
> Kyle
>
>
> Bryan Murphy <bryan at terralab.com> writes:
>
> > This is what I use. It restarts myth if it crashes, but not if you exit
> > it normally. Modify to fit your environment.
> >
> > #!/bin/sh
> >
> > export DISPLAY=":0.1"
> > xset -display :0.1 -dpms
> > xset -display :0.1 s off
> >
> > until [ "$?" == "1" ]; do
> > /opt/MythTV/bin/mythfrontend > /tmp/mythfrontend.log 2>&1
> > done
>
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>
>
>
More information about the mythtv-users
mailing list