[Pkg-nagios-changes] [SCM] Debian packaging for mod gearman. branch, master, updated. debian/1.3.0-1-7-g46a112f

Stig Sandbeck Mathisen ssm at debian.org
Wed Jun 6 22:30:15 UTC 2012


The following commit has been merged in the master branch:
commit 9ea3ee4882c7e17e6f6a7791a40a23ad6b7ed3f5
Author: Alexander Wirt <formorer at debian.org>
Date:   Thu Jun 7 00:15:07 2012 +0200

    Update init script (Closes: #676415)

diff --git a/debian/mod-gearman-worker.init b/debian/mod-gearman-worker.init
index d4dd17b..7b7746b 100755
--- a/debian/mod-gearman-worker.init
+++ b/debian/mod-gearman-worker.init
@@ -30,48 +30,74 @@ if [ -e /etc/default/mod-gearman-worker ]; then
     . /etc/default/mod-gearman-worker
 fi
 
-abort_if_unconfigured() {
-    if [ ! -e "$CONFIG" ]; then
-        log_failure_msg "mod-gearman-worker is unconfigured."
-        exit 6
-    fi
+# this is from madduck on IRC, 2006-07-06
+# There should be a better possibility to give daemon error messages
+# and/or to log things
+log()
+{
+  case "$1" in
+    [[:digit:]]*) success=$1; shift;;
+    *) :;;
+  esac
+  log_action_begin_msg "$1"; shift
+  log_action_end_msg ${success:-0} "$*"
 }
 
 pre_start() {
+    if [ ! -e "$CONFIG" ]; then
+        log 1 "Configuration file $CONFIG not present"
+	exit 1
+    fi
     install -o $USER -g $USER -d $(dirname $PIDFILE)
 }
 
 start_worker() {
     start-stop-daemon --start --oknodo --user $USER --exec $DAEMON --quiet \
-        --chuid $USER --pidfile $PIDFILE -- $DAEMON_OPTS
+        --chuid $USER --pidfile $PIDFILE -- $DAEMON_OPTS || return 2
 }
 
 stop_worker() {
     start-stop-daemon --stop --oknodo --user $USER --exec $DAEMON --quiet \
         --retry 10 --pidfile $PIDFILE
+    RETVAL="$?"
+    [ "$RETVAL" = 2 ] && return 2
+    # Wait for children to finish too if this is a daemon that forks
+    # and if the daemon is only ever run from this initscript.
+    # If the above conditions are not satisfied then add some other code
+    # that waits for the process to drop all resources that could be
+    # needed by services started subsequently.  A last resort is to
+    # sleep for some time.
+    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --user $USER --exec $DAEMON
+    [ "$?" = 2 ] && return 2
 }
 
 reload_worker() {
     start-stop-daemon --stop --oknodo --user $USER --exec $DAEMON --quiet \
         --signal HUP --pidfile $PIDFILE
+    return 0
 }
 
 status_worker() {
-    status_of_proc -p $PIDFILE $DAEMON $NAME
+    status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
 }
 
 case "$1" in
     start)
-	abort_if_unconfigured
-        log_daemon_msg "Starting $DESC" "$NAME"
         pre_start
+        log_daemon_msg "Starting $DESC" "$NAME"
         start_worker
-        log_end_msg $?
+	case "$?" in
+		0|1) log_end_msg 0 ;;
+		2) log_end_msg 1 ;;
+	esac
         ;;
     stop)
         log_daemon_msg "Stopping $DESC" "$NAME"
         stop_worker
-        log_end_msg $?
+	case "$?" in
+		0|1) log_end_msg 0 ;;
+		2) log_end_msg 1 ;;
+	esac
         ;;
     reload|force-reload)
         log_daemon_msg "Reloading $DESC" "$NAME"
@@ -79,12 +105,26 @@ case "$1" in
         log_end_msg $?
         ;;
     status)
-        status_worker
+        status_worker && exit 0 || exit $?
         ;;
     restart)
-        $0 stop
-        $0 start
-        ;;
+	log_daemon_msg "Restarting $DESC" "$NAME"
+        stop_worker
+	case "$?" in
+	      0|1)
+        	start_worker
+	        case "$?" in
+        	    0) log_end_msg 0 ;;
+	            1) log_end_msg 1 ;; # Old process is still running
+	            *) log_end_msg 1 ;; # Failed to start
+	        esac
+        	;;
+      	      *)
+	        # Failed to stop
+        	log_end_msg 1
+	        ;;
+	esac
+	;;
     *)
         echo "Usage: $0 [start|stop|status|reload|force-reload|restart]"
         exit 1

-- 
Debian packaging for mod gearman.



More information about the Pkg-nagios-changes mailing list