2012-01-26 16:50:48 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# rabbitmq-server RabbitMQ broker
|
|
|
|
#
|
|
|
|
# chkconfig: - 80 05
|
|
|
|
# description: Enable AMQP service provided by RabbitMQ
|
|
|
|
#
|
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: rabbitmq-server
|
2017-02-06 17:06:05 +01:00
|
|
|
# Required-Start: $local_fs $network $remote_fs epmd
|
|
|
|
# Required-Stop: $local_fs $network $remote_fs epmd
|
2012-01-26 16:50:48 +01:00
|
|
|
# Default-Start: 3 5
|
|
|
|
# Default-Stop: 0 1 2 4 6
|
|
|
|
# Description: RabbitMQ broker
|
|
|
|
# Short-Description: Enable AMQP service provided by RabbitMQ broker
|
|
|
|
### END INIT INFO
|
|
|
|
|
2012-12-14 14:33:31 +01:00
|
|
|
# Source function library
|
|
|
|
. /etc/rc.status
|
|
|
|
|
|
|
|
rc_reset
|
|
|
|
|
2012-01-26 16:50:48 +01:00
|
|
|
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
|
|
|
NAME=rabbitmq-server
|
|
|
|
DAEMON=/usr/sbin/${NAME}
|
|
|
|
CONTROL=/usr/sbin/rabbitmqctl
|
|
|
|
DESC=rabbitmq-server
|
|
|
|
USER=rabbitmq
|
|
|
|
ROTATE_SUFFIX=
|
|
|
|
INIT_LOG_DIR=/var/log/rabbitmq
|
|
|
|
PID_FILE=/var/run/rabbitmq/pid
|
|
|
|
|
|
|
|
DEFAULTS_FILE=/etc/sysconfig/rabbitmq-server
|
|
|
|
LOCK_FILE=/var/run/rabbitmq/lock
|
|
|
|
|
|
|
|
test -x $DAEMON || exit 0
|
|
|
|
test -x $CONTROL || exit 0
|
|
|
|
|
|
|
|
# Include rabbitmq defaults if available
|
|
|
|
if [ -f "$DEFAULTS_FILE" ] ; then
|
|
|
|
. $DEFAULTS_FILE
|
|
|
|
export RABBITMQ_MNESIA_BASE RABBITMQ_LOG_BASE \
|
|
|
|
RABBITMQ_NODENAME RABBITMQ_NODE_IP_ADDRESS RABBITMQ_NODE_PORT \
|
|
|
|
RABBITMQ_CLUSTER_CONFIG_FILE RABBITMQ_CONFIG_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p /var/run/rabbitmq
|
2012-02-07 15:03:34 +01:00
|
|
|
chown rabbitmq. /var/run/rabbitmq
|
2012-01-26 16:50:48 +01:00
|
|
|
|
|
|
|
start_rabbitmq () {
|
|
|
|
status_rabbitmq quiet
|
2012-12-14 14:33:31 +01:00
|
|
|
if [ $? -eq 0 ] ; then
|
|
|
|
return 0
|
2012-01-26 16:50:48 +01:00
|
|
|
else
|
2013-04-04 11:48:47 +02:00
|
|
|
export RABBITMQ_PID_FILE=$PID_FILE
|
|
|
|
startproc -l ${INIT_LOG_DIR}/startup_log -p $PID_FILE $DAEMON
|
2012-01-26 16:50:48 +01:00
|
|
|
$CONTROL wait $PID_FILE >/dev/null 2>&1
|
2012-12-14 14:33:31 +01:00
|
|
|
rc=$?
|
|
|
|
case "$rc" in
|
2012-01-26 16:50:48 +01:00
|
|
|
0)
|
|
|
|
if [ -n "$LOCK_FILE" ] ; then
|
|
|
|
touch $LOCK_FILE
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
rm -f $PID_FILE
|
|
|
|
echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}
|
2012-12-14 14:33:31 +01:00
|
|
|
rc=1
|
2012-01-26 16:50:48 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2012-12-14 14:33:31 +01:00
|
|
|
return $rc
|
2012-01-26 16:50:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
stop_rabbitmq () {
|
|
|
|
status_rabbitmq quiet
|
2012-12-14 14:33:31 +01:00
|
|
|
if [ $? -eq 0 ] ; then
|
2012-01-26 16:50:48 +01:00
|
|
|
$CONTROL stop > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
|
2012-12-14 14:33:31 +01:00
|
|
|
rc=$?
|
|
|
|
if [ $rc -eq 0 ] ; then
|
2012-01-26 16:50:48 +01:00
|
|
|
rm -f $PID_FILE
|
|
|
|
if [ -n "$LOCK_FILE" ] ; then
|
|
|
|
rm -f $LOCK_FILE
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err
|
|
|
|
fi
|
|
|
|
else
|
2012-12-14 14:33:31 +01:00
|
|
|
rc=0
|
2012-01-26 16:50:48 +01:00
|
|
|
fi
|
2012-12-14 14:33:31 +01:00
|
|
|
return $rc
|
2012-01-26 16:50:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
status_rabbitmq() {
|
2012-12-14 14:33:31 +01:00
|
|
|
rc=0
|
2012-01-26 16:50:48 +01:00
|
|
|
if [ "$1" != "quiet" ] ; then
|
|
|
|
$CONTROL status 2>&1
|
|
|
|
else
|
|
|
|
$CONTROL status > /dev/null 2>&1
|
|
|
|
fi
|
2012-12-14 14:33:31 +01:00
|
|
|
if [ $? -ne 0 ] ; then
|
|
|
|
rc=3
|
2012-01-26 16:50:48 +01:00
|
|
|
fi
|
2012-12-14 14:33:31 +01:00
|
|
|
return $rc
|
2012-01-26 16:50:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
rotate_logs_rabbitmq() {
|
2012-12-14 14:33:31 +01:00
|
|
|
rc=0
|
2012-01-26 16:50:48 +01:00
|
|
|
$CONTROL rotate_logs ${ROTATE_SUFFIX}
|
|
|
|
if [ $? != 0 ] ; then
|
2012-12-14 14:33:31 +01:00
|
|
|
rc=1
|
2012-01-26 16:50:48 +01:00
|
|
|
fi
|
2012-12-14 14:33:31 +01:00
|
|
|
return $rc
|
2012-01-26 16:50:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
restart_running_rabbitmq () {
|
|
|
|
status_rabbitmq quiet
|
2012-12-14 14:33:31 +01:00
|
|
|
if [ $? -eq 0 ] ; then
|
2012-01-26 16:50:48 +01:00
|
|
|
restart_rabbitmq
|
|
|
|
else
|
|
|
|
echo RabbitMQ is not runnning
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
restart_rabbitmq() {
|
2012-12-14 14:33:31 +01:00
|
|
|
$0 stop
|
|
|
|
$0 start
|
2012-01-26 16:50:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
echo -n "Starting $DESC: "
|
|
|
|
start_rabbitmq
|
2012-12-14 14:33:31 +01:00
|
|
|
rc_status -v
|
2012-01-26 16:50:48 +01:00
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
echo -n "Stopping $DESC: "
|
|
|
|
stop_rabbitmq
|
2012-12-14 14:33:31 +01:00
|
|
|
rc_status -v
|
2012-01-26 16:50:48 +01:00
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status_rabbitmq
|
2012-12-14 14:33:31 +01:00
|
|
|
rc_status # no verbose here -- status function already prints status out
|
2012-01-26 16:50:48 +01:00
|
|
|
;;
|
|
|
|
rotate-logs)
|
|
|
|
echo -n "Rotating log files for $DESC: "
|
|
|
|
rotate_logs_rabbitmq
|
2012-12-14 14:33:31 +01:00
|
|
|
rc_status
|
2012-01-26 16:50:48 +01:00
|
|
|
;;
|
|
|
|
force-reload|reload|restart)
|
|
|
|
restart_rabbitmq
|
2012-12-14 14:33:31 +01:00
|
|
|
rc_status
|
2012-01-26 16:50:48 +01:00
|
|
|
;;
|
|
|
|
condrestart|try-restart)
|
|
|
|
restart_running_rabbitmq
|
2012-12-14 14:33:31 +01:00
|
|
|
rc_status
|
2012-01-26 16:50:48 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
|
2012-12-14 14:33:31 +01:00
|
|
|
exit 1
|
2012-01-26 16:50:48 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-12-14 14:33:31 +01:00
|
|
|
rc_exit
|