[Pkg-sympa-commits] [SCM] sympa Debian packaging branch, master, updated. debian/6.1.7_dfsg-1-14-g351ae33

Emmanuel Bouthenot kolter at openics.org
Sun Dec 4 19:25:38 UTC 2011


The following commit has been merged in the master branch:
commit 2ae6cb137092101d1504241a3af581484ca220c2
Author: Emmanuel Bouthenot <kolter at openics.org>
Date:   Sun Dec 4 18:20:24 2011 +0000

    Cleanup and bug fixes in init script

diff --git a/debian/sympa.init b/debian/sympa.init
index 72126f1..8e887dd 100644
--- a/debian/sympa.init
+++ b/debian/sympa.init
@@ -53,14 +53,16 @@ create_rundir() {
     chmod 0755 "$RUNDIR"
 }
 
-get_daemon_pid() {
-    ps -eo pid,user,cmd|egrep "^[0-9]+ ${USER} .* ${EXECPATH}/${1}.pl" | cut -d ' ' -f1
+get_daemon_pids() {
+    ps -eo pid,user,cmd | sed 's/^[[:space:]]*//' \
+    | egrep "^[0-9]+ ${USER} .* ${EXECPATH}/${1}.pl" \
+    | cut -d ' ' -f1 | tr '\n' ' ' | sed 's/[[:space:]]*$//'
 }
 
 isrunning_sympa() {
     RET=1
     for daemon in $DAEMONS ; do
-        if [ "$(get_daemon_pid "$daemon")" != "" ]; then
+        if [ "$(get_daemon_pids "$daemon")" != "" ]; then
             RET=0
             break
         fi
@@ -71,9 +73,9 @@ isrunning_sympa() {
 status_sympa() {
     log_daemon_msg "Status of $DESC"
     for daemon in $DAEMONS ; do
-        pid=$(get_daemon_pid "$daemon")
-        if [ "$pid" != "" ]; then
-            log_progress_msg "$daemon (pid $pid)"
+        pids=$(get_daemon_pids "$daemon")
+        if [ "$pids" != "" ]; then
+            log_progress_msg "$daemon (pid $pids)"
         else
             log_progress_msg "$daemon (not running)"
         fi
@@ -99,24 +101,37 @@ start_sympa() {
         fi
     else
         log_progress_msg "$NAME is already running (see status command)"
-        log_end_msg 1
+        log_end_msg 0
     fi
 }
 
 stop_sympa() {
     ERRORS=
     log_daemon_msg "Stoping $DESC"
-    for daemon in $(reverse_order "$DAEMONS") ; do
-        log_progress_msg "$daemon"
-        start-stop-daemon --stop --quiet \
-            --pidfile "${RUNDIR}/${daemon}.pid" || ERRORS="$ERRORS $daemon"
-    done
-    log_end_msg 0
-    if [ "$1" != "--quiet" ]; then
+    if isrunning_sympa ; then
+        for daemon in $(reverse_order "$DAEMONS") ; do
+            log_progress_msg "$daemon"
+            start-stop-daemon --stop --quiet --retry 5 \
+                --pidfile "${RUNDIR}/${daemon}.pid" || ERRORS="$ERRORS $daemon"
+            # It may happened that some processes are not tracked with pidfiles.
+            # For example, with the parameter 'distribution_mode fork' used by
+            # sympa.pl. It forked but the second process pid is not tracked,
+            # here is some kind of 'garbage collector'
+            pids=$(get_daemon_pids "$daemon")
+            if [ "$pids" != "" ]; then
+                for p in $pids ; do
+                    kill -TERM "$p" 2>/dev/null || true
+                done
+            fi
+        done
+        log_end_msg 0
         if [ "$ERRORS" != "" ]; then
             log_daemon_msg "Some daemons failed to be stopped (not running?):$ERRORS"
             log_end_msg 1
         fi
+    else
+        log_progress_msg "$NAME is already stopped"
+        log_end_msg 0
     fi
 }
 
@@ -128,7 +143,7 @@ case "$1" in
         stop_sympa
         ;;
     restart)
-        stop_sympa --quiet
+        stop_sympa
         start_sympa
         ;;
     reload|force-reload)

-- 
sympa Debian packaging



More information about the Pkg-sympa-commits mailing list