fix log_call deadlock
[nodemanager.git] / initscripts / nm
index 61b7254..cb58689 100755 (executable)
 # Source function library.
 . /etc/init.d/functions
 
-if [ -f /etc/sysconfig/NodeManager ]; then
-    . /etc/sysconfig/NodeManager
-fi
+[ -f /etc/sysconfig/NodeManager ] && . /etc/sysconfig/NodeManager
 
-nm=${NM-"python /usr/share/NodeManager/nm.py"}
-prog="Node Manager"
 options=${OPTIONS-"-d -s"}
 restartoptions=${RESTARTOPTIONS-"-d"}
+# turn on verbosity
+verboseoptions=${DEBUGOPTIONS-"-v -d"}
+# debug mode is interactive, and has faster period
+debugoptions=${DEBUGOPTIONS-"-v -p 30 -r 15"}
+
+nm=${NM-"python /usr/share/NodeManager/nm.py"}
+prog="Node Manager"
 pidfile=${PIDFILE-/var/run/nm.pid}
 lockfile=${LOCKFILE-/var/lock/subsys/nm}
+
 RETVAL=0
 
-do_start()
-{
+function start() {
     echo -n $"Starting $prog: "
     daemon --check=nm $nm "$@"
     RETVAL=$?
@@ -34,13 +37,7 @@ do_start()
     return $RETVAL
 }
 
-start()
-{
-    do_start $options
-}
-
-stop()
-{
+function stop() {
     echo -n $"Stopping $prog: "
     killproc nm
     RETVAL=$?
@@ -48,35 +45,41 @@ stop()
     [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile}
 }
 
-restart()
-{
-    stop
-    do_start $restartoptions
-}
-
-
 case "$1" in
     start)
-    start
-    ;;
+       start $options
+       ;;
     stop)
-    stop
-    ;;
+       stop
+       ;;
     status)
-    status $nm
-    RETVAL=$?
-    ;;
+       status $nm
+       RETVAL=$?
+       ;;
     restart|reload)
-    restart
-    ;;
+       shift
+       stop
+       start $restartoptions "$@"
+       ;;
     condrestart)
-    if [ -f ${pidfile} ] ; then
-        restart
-    fi
-    ;;
+       shift
+       [ -f ${pidfile} ] && { stop; start $restartoptions "$@"; }
+       ;;
+    restartverbose)
+       shift
+       stop
+       $nm $verboseoptions "$@"
+       ;;
+    restartdebug)
+       shift
+       stop
+       echo "Restarting with $debugoptions $@ .."
+       $nm $debugoptions "$@"
+       ;;
     *)
-    echo $"Usage: $0 {start|stop|restart|condrestart|status}"
-    exit 1
+       echo $"Usage: $0 {start|stop|status|restart|condrestart|restartdebug [-d]}"
+       exit 1
+       ;;
 esac
 
-exit 0
+exit $RETVAL