]> matita.cs.unibo.it Git - helm.git/blob - helm/scripts/init.d/uwobo_forever.sh
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / scripts / init.d / uwobo_forever.sh
1 #!/bin/sh
2 #
3 # respawner for UWOBO (http://helm.cs.unibo.it/software/uwobo)
4 #
5 # by --Zack <zack@cs.unibo.it>
6 #
7 # Created: Mon,  7 Apr 2003 18:59:56 +0200 zacchiro
8 # Last-Modified: Tue,  8 Apr 2003 10:06:41 +0200 zacchiro
9 #
10
11 # Warning: $PIDFILE value is shared by UWOBO /etc/init.d script, change at your
12 # own risk
13 PIDFILE="/projects/helm/run/uwobo_mowgli.pid"
14
15 MAILTO="root@mowgli.cs.unibo.it"
16 INTERVAL="60"
17
18 # Usage: alert <subject> <body>
19 alert ()
20 {
21   echo "$2" | mail -s "$1" $MAILTO
22 }
23
24 # check if uwobo is still alive
25 uwobo_is_alive ()
26 {
27    if [ -r "$PIDFILE" ]; then
28      ps `cat $PIDFILE` &> /dev/null
29    else # no pid file found, uwobo has been shutdown nicely
30      exit 0
31    fi
32 }
33
34 # start uwobo
35 start_uwobo ()
36 {
37    /etc/init.d/helm-uwobo_mowgli start &
38 }
39
40 # first check
41 if ! uwobo_is_alive; then
42    alert "UWOBO failed to start :-((" "UWOBO died during initialization :-((, enjoy debugging! :-P. Cheers."
43    exit 0
44 fi
45
46 # continuous checks
47 while true; do
48    sleep $INTERVAL
49    if ! uwobo_is_alive; then
50       alert "UWOBO died :-(, restarting it ..." "UWOBO died miserably :-(. I'm going to try restarting it, you will receive an additional mail in case of failure. Cheers."
51       start_uwobo # performed in background
52       exit 0
53    fi
54 done
55