supervisor init script doesn't wait for supervisor to stop

Bug #1427434 reported by Justin Patrin on 2015-03-03
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
supervisor (Ubuntu)
Undecided
Unassigned

Bug Description

Since the supervisor doesn't block while stopping the init script returns from the stop command before the process dies. The following patch fixes this:

diff --git a/debian/supervisor.init b/debian/supervisor.init
index 334d4c6..49ed69b 100644
--- a/debian/supervisor.init
+++ b/debian/supervisor.init
@@ -100,10 +100,18 @@ case "$1" in
         fi
        ;;
   stop)
- echo -n "Stopping $DESC: "
- start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
- echo "$NAME."
- ;;
+ echo -n "Stopping $DESC: "
+ if [ -e $PIDFILE ]; then
+ pid=$(cat $PIDFILE)
+ fi
+ start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
+ if [ ! -z "$pid" ]; then
+ while [ -e /proc/$pid ]; do
+ sleep 1;
+ done
+ fi
+ echo "$NAME."
+ ;;
   force-stop)
        echo -n "Forcefully stopping $DESC: "
         force_stop

Justin Patrin (jpatrin) on 2015-03-03
description: updated
description: updated
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers