[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Wait until mixminion is dead in init script stop
Update of /home/minion/cvsroot/src/minion/debian
In directory moria.mit.edu:/tmp/cvs-serv29660
Modified Files:
changelog mixminion.init
Log Message:
Wait until mixminion is dead in init script stop
Index: changelog
===================================================================
RCS file: /home/minion/cvsroot/src/minion/debian/changelog,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- changelog 28 Jul 2004 12:54:21 -0000 1.12
+++ changelog 2 Oct 2004 16:30:07 -0000 1.13
@@ -1,9 +1,12 @@
mixminion (0.0.XXXXX) unreleased; urgency=low
* Update debian/copyright: Mixminion relicensed to MIT.
- * Build depend on python too, in addition to python2.3.
+ * Build depend on python too, in addition to python2.3
+ (closes: #271922, #271202).
+ * Wait until mixminion is dead in init script stop
+ (closes: #257758).
- -- Peter Palfrader <weasel@debian.org> Wed, 28 Jul 2004 14:53:54 +0200
+ -- Peter Palfrader <weasel@debian.org> Sat, 2 Oct 2004 18:29:12 +0200
mixminion (0.0.7.1-1) experimental; urgency=low
Index: mixminion.init
===================================================================
RCS file: /home/minion/cvsroot/src/minion/debian/mixminion.init,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mixminion.init 14 Dec 2003 02:30:46 -0000 1.1
+++ mixminion.init 2 Oct 2004 16:30:07 -0000 1.2
@@ -4,6 +4,10 @@
DAEMON=/usr/bin/mixminion
NAME=mixminion
DESC="mixminion daemon"
+PIDFILE=/var/run/$NAME/mixminion.pid
+WAITFORDAEMON=15
+PYTHON=/usr/bin/python2.3
+PYTHON_BASE=`basename $PYTHON`
test -x $DAEMON || exit 0
@@ -14,6 +18,32 @@
set -e
+
+wait_for_deaddaemon () {
+ pid=$1
+ sleep 1
+ if test -n "$pid"
+ then
+ if kill -0 $pid 2>/dev/null
+ then
+ echo -n "."
+ cnt=0
+ while kill -0 $pid 2>/dev/null
+ do
+ cnt=`expr $cnt + 1`
+ if [ $cnt -gt $WAITFORDAEMON ]
+ then
+ echo " FAILED."
+ return 1
+ fi
+ sleep 1
+ echo -n "."
+ done
+ fi
+ fi
+ return 0
+}
+
case "$1" in
start)
if [ "$RUN_DAEMON" != "yes" ]; then
@@ -22,21 +52,44 @@
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --oknodo \
--chuid debian-mixminion:debian-mixminion \
- --pidfile /var/run/$NAME/mixminion.pid \
- --exec /usr/bin/python2.3 -- /usr/bin/mixminion server-start --daemon --quiet
+ --pidfile $PIDFILE \
+ --exec $PYTHON \
+ -- /usr/bin/mixminion server-start --daemon --quiet
echo "$NAME."
fi
;;
stop)
echo -n "Stopping $DESC: "
- start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/$NAME/mixminion.pid \
- --exec /usr/bin/python2.3 -- /usr/bin/mixminion
- echo "$NAME."
+ pid=`cat $PIDFILE 2>/dev/null` || true
+ if test ! -f $PIDFILE -o -z "$pid"
+ then
+ echo "not running (there is no $PIDFILE)."
+ elif start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $PYTHON_BASE
+ then
+ wait_for_deaddaemon $pid
+ echo "$NAME."
+ elif kill -0 $pid 2>/dev/null
+ then
+ echo "FAILED (Is $pid not $NAME?)."
+ else
+ echo "FAILED ($DAEMON died: process $pid not running; or permission denied)."
+ fi
;;
reload|force-reload)
- echo "Reloading $DESC configuration."
- start-stop-daemon --stop --signal 1 --oknodo --quiet --pidfile /var/run/$NAME/mixminion.pid \
- --exec /usr/bin/python2.3 -- /usr/bin/mixminion
+ echo -n "Reloading $DESC configuration: "
+ pid=`cat $PIDFILE 2>/dev/null` || true
+ if test ! -f $PIDFILE -o -z "$pid"
+ then
+ echo "not running (there is no $PIDFILE)."
+ elif start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $PYTHON_BASE
+ then
+ echo "$NAME."
+ elif kill -0 $pid 2>/dev/null
+ then
+ echo "FAILED (Is $pid not $NAME?)."
+ else
+ echo "FAILED ($DAEMON died: process $pid not running; or permission denied)."
+ fi
;;
restart)
$0 stop