X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=debian%2Fmcollective.init;fp=debian%2Fmcollective.init;h=f599f4a8b5a6010ed0559bcf0de085ac7b82b59e;hb=d1f1649ba43c5cbc43c4beb2380096ba051d646a;hp=6b02d0b06572066b6aefa05a5db090168190e5ca;hpb=8a3fe7daeecccf43dd71c59371c5005400d35101;p=packages%2Fprecise%2Fmcollective.git diff --git a/debian/mcollective.init b/debian/mcollective.init old mode 100755 new mode 100644 index 6b02d0b..f599f4a --- a/debian/mcollective.init +++ b/debian/mcollective.init @@ -24,11 +24,11 @@ uid=`id -u` # PID directory -pidfile="/var/run/mcollective.pid" +pidfile="/var/run/mcollectived.pid" name="mcollective" mcollectived=/usr/sbin/mcollectived -daemonopts="--config=/etc/mcollective/server.cfg" +daemonopts="--pid=${pidfile} --config=/etc/mcollective/server.cfg" # Source function library. @@ -41,30 +41,22 @@ 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 - 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 + start-stop-daemon -S -p ${pidfile} --oknodo -q -a ${mcollectived} -- ${daemonopts} + [ $? = 0 ] && { exit 0 ; } || { exit 1 ; } log_success_msg "mcollective started" + touch $lock ;; stop) echo "Stopping daemon: " $name - /sbin/start-stop-daemon --stop -q --pidfile $pidfile - if [ -f $pidfile ]; then - rm -f $pidfile - fi + start-stop-daemon -K -R 5 -s "TERM" --oknodo -q -p ${pidfile} [ $? = 0 ] && { exit 0 ; } || { exit 1 ; } log_success_msg "mcollective stopped" ;; @@ -75,6 +67,14 @@ 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 $? ;;