From 327162e6e319ff38447992668e0753363b870b6e Mon Sep 17 00:00:00 2001 From: Dmitry Burmistrov Date: Thu, 10 Oct 2013 17:34:39 +0400 Subject: [PATCH] Update mcollective.init --- mcollective.init | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/mcollective.init b/mcollective.init index d1a9163..6fb229b 100644 --- a/mcollective.init +++ b/mcollective.init @@ -24,11 +24,11 @@ uid=`id -u` # PID directory -pidfile="/var/run/mcollectived.pid" +pidfile="/var/run/mcollective.pid" name="mcollective" mcollectived=/usr/sbin/mcollectived -daemonopts="--pid=${pidfile} --config=/etc/mcollective/server.cfg" +daemonopts="--config=/etc/mcollective/server.cfg" # Source function library. @@ -41,22 +41,30 @@ then exit 5 fi -# create pid file if it does not exist -[ ! -f ${pidfile} ] && { touch ${pidfile} ; } - # See how we were called. case "$1" in start) echo "Starting daemon: " $name # start the program - start-stop-daemon -S -b -p ${pidfile} --oknodo -q -a ${mcollectived} -- ${daemonopts} - [ $? = 0 ] && { exit 0 ; } || { exit 1 ; } + if [ -f $pidfile ]; then + if [ -f "$(cat /proc/$(cat $pidfile)/exe > /dev/null)" ] ; then + echo MCollective appears to be running + exit 1 + else + /sbin/start-stop-daemon --start -b --quiet --oknodo -m --pidfile $pidfile --exec $mcollectived -- $daemonopts + [ $? = 0 ] && { exit 0 ; } || { exit 1 ; } + fi + else + /sbin/start-stop-daemon --start -b --quiet --oknodo -m --pidfile $pidfile --exec $mcollectived -- $daemonopts + fi log_success_msg "mcollective started" - touch $lock ;; stop) echo "Stopping daemon: " $name - start-stop-daemon -K -R 5 -s "TERM" --oknodo -q -p ${pidfile} + /sbin/start-stop-daemon --stop -q --pidfile $pidfile + if [ -f $pidfile ]; then + rm -f $pidfile + fi [ $? = 0 ] && { exit 0 ; } || { exit 1 ; } log_success_msg "mcollective stopped" ;; @@ -67,14 +75,6 @@ case "$1" in $0 start [ $? = 0 ] && { echo "mcollective restarted" ; exit 0 ; } ;; - condrestart) - if [ -f $lock ]; then - $0 stop - # avoid race - sleep 2 - $0 start - fi - ;; status) status_of_proc -p ${pidfile} ${mcollectived} ${name} && exit 0 || exit $? ;; -- 2.32.3