Added ReCreate. Also added try catch to api eval of rpc method.
[nodemanager.git] / nm.init
1 #!/bin/bash
2 #
3 # nm       Starts and stops Node Manager daemon
4 #
5 # chkconfig: 3 86 26
6 # description: Starts and stops Node Manager daemon
7 #
8
9 # Source function library.
10 . /etc/init.d/functions
11
12 if [ -f /etc/sysconfig/NodeManager ]; then
13     . /etc/sysconfig/NodeManager
14 fi
15
16 nm=${NM-"python /usr/share/NodeManager/nm.py"}
17 prog="Node Manager"
18 restartoptions=
19 pidfile=${PIDFILE-/var/run/nm.pid}
20 lockfile=${LOCKFILE-/var/lock/subsys/nm}
21 RETVAL=0
22
23 do_start()
24 {
25     options=$1
26     echo -n $"Starting $prog: "
27     daemon --check=nm $nm $options
28     RETVAL=$?
29     echo
30     [ $RETVAL -eq 0 ] && touch ${lockfile}
31     return $RETVAL
32 }
33
34 start()
35 {
36     do_start ${OPTIONS-"-d -s"}
37 }
38
39 stop()
40 {
41     echo -n $"Stopping $prog: "
42     killproc nm
43     RETVAL=$?
44     echo
45     [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile}
46     for i in $( vps aux | grep nm.py | awk '{print $2}' ); do
47         kill -9 $i
48     done
49
50 }
51
52 restart()
53 {
54     stop
55     do_start ${OPTIONS-"-d"}
56 }
57
58
59 case "$1" in
60     start)
61     start
62     ;;
63     stop)
64     stop
65     ;;
66     status)
67     status $nm
68     RETVAL=$?
69     ;;
70     restart|reload)
71     restart
72     ;;
73     condrestart)
74     if [ -f ${pidfile} ] ; then
75         restart
76     fi
77     ;;
78     *)
79     echo $"Usage: $0 {start|stop|restart|condrestart|status}"
80     exit 1
81 esac
82
83 exit 0