fuel-library/files/rabbit-fence/rabbit-fence.init
Vladimir Kuklin 6e6d1cb23c Ensure the rabbit-fence daemon started and respawned
W/o this fix, if the daemon crashed, it
would remain stopped. Also, the rabbit fence
daemon will crash on start, when there is no
/var/run/rabbitmq piddir exist.

The solution is
* add the respawn option to
the daemon's upstart (TODO for Centos inittab)
* and ensure the piddir
created by upstart/init.d before starting the daemon.

This also requires to add the rabbitmq and
fuel-rabbit-fence packages as a dependency.

Closes-bug: #1456791

Change-Id: I4e71eb9e4aa4ff3b877aa89a37d82215740aaeab
Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
2015-05-23 00:09:33 +00:00

66 lines
1015 B
Bash

#!/bin/bash
# rabbit-fence RabbitMQ fence
#
# chkconfig: 2345 24 79
# description: Starts/Stops RabbitMQ fence daemon
#
# processname: rabbit-fence.py
# Source function library.
. /etc/rc.d/init.d/functions
prog="rabbit-fence"
script="/usr/bin/${prog}.py"
piddir="/var/run/rabbitmq"
pidfile="${piddir}/${prog}.pid"
user="rabbitmq"
[ -x $script ] || exit 0
[ -d $piddir ] || (mkdir -p $piddir; chown -R $user $piddir)
start() {
exec $script
return $?
}
stop() {
PID=$(cat $pidfile)
kill $PID
retval=$?
[ $retval -eq 0 ] && (rm -f $pidfile || true)
return $retval
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
restart() {
stop
start
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
status)
rh_status
;;
*)
echo Usage: start|stop|restart|status
exit 2
esac