Fix start/stop in init script

This commit is contained in:
Kim Ho 2013-08-30 11:03:16 -07:00
parent d33ada5c97
commit 1de8f9686e

View File

@ -27,7 +27,7 @@
if [ -f /etc/default/salt ]; then if [ -f /etc/default/salt ]; then
. /etc/default/salt . /etc/default/salt
else else
SALTAPI=/usr/bin/salt-api -d SALTAPI=/usr/bin/salt-api
PYTHON=/usr/bin/python PYTHON=/usr/bin/python
fi fi
@ -48,6 +48,7 @@ fi
SERVICE=salt-api SERVICE=salt-api
PROCESS=salt-api PROCESS=salt-api
CONFIG_ARGS="-d" CONFIG_ARGS="-d"
PID_FILE="/var/run/salt-api.pid"
RETVAL=0 RETVAL=0
@ -65,7 +66,13 @@ start() {
RETVAL=0 RETVAL=0
fi fi
else else
daemon --check $SERVICE $SALTAPI -d $CONFIG_ARGS if status $PROCESS &> /dev/null; then
failure "Already running."
RETVAL=1
else
daemon --pidfile=$PID_FILE --check $SERVICE $SALTAPI $CONFIG_ARGS
RETVAL=0
fi
fi fi
RETVAL=$? RETVAL=$?
echo echo
@ -87,10 +94,18 @@ stop() {
RETVAL=1 RETVAL=1
fi fi
else else
killproc $PROCESS if [ -f $PID_FILE ] && cat $PID_FILE | xargs pkill -P &> /dev/null; then
success
RETVAL=0
rm -f $PID_FILE
else
failure "$PID_FILE does not exist or could not kill."
RETVAL=1
fi
fi fi
RETVAL=$? RETVAL=$?
echo echo
return $RETVAL
} }
restart() { restart() {