Blame rabbitmq-server.init

Hubert Plociniczak cc9fdf
#!/bin/sh
Hubert Plociniczak cc9fdf
#
Hubert Plociniczak cc9fdf
# rabbitmq-server RabbitMQ broker
Hubert Plociniczak cc9fdf
#
Hubert Plociniczak cc9fdf
# chkconfig: - 80 05
Hubert Plociniczak cc9fdf
# description: Enable AMQP service provided by RabbitMQ
Hubert Plociniczak cc9fdf
#
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
### BEGIN INIT INFO
Hubert Plociniczak cc9fdf
# Provides:          rabbitmq-server
Hubert Plociniczak cc9fdf
# Default-Start:
Hubert Plociniczak cc9fdf
# Default-Stop:
Hubert Plociniczak cc9fdf
# Required-Start:    $remote_fs $network
Hubert Plociniczak cc9fdf
# Required-Stop:     $remote_fs $network
Hubert Plociniczak cc9fdf
# Description:       RabbitMQ broker
Hubert Plociniczak cc9fdf
# Short-Description: Enable AMQP service provided by RabbitMQ broker
Hubert Plociniczak cc9fdf
### END INIT INFO
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
PATH=/sbin:/usr/sbin:/bin:/usr/bin
Hubert Plociniczak cc9fdf
DAEMON=/usr/sbin/rabbitmq-multi
Hubert Plociniczak cc9fdf
NAME=rabbitmq-server
Hubert Plociniczak cc9fdf
DESC=rabbitmq-server
Hubert Plociniczak cc9fdf
USER=rabbitmq
Hubert Plociniczak cc9fdf
NODE_COUNT=1
Hubert Plociniczak cc9fdf
ROTATE_SUFFIX=
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
LOCK_FILE=/var/lock/subsys/$NAME
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
test -x $DAEMON || exit 0
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
# Include rabbitmq defaults if available
Hubert Plociniczak cc9fdf
if [ -f /etc/sysconfig/rabbitmq ] ; then
Hubert Plociniczak cc9fdf
	. /etc/sysconfig/rabbitmq
Hubert Plociniczak cc9fdf
fi
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
RETVAL=0
Hubert Plociniczak cc9fdf
set -e
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
start_rabbitmq () {
Hubert Plociniczak cc9fdf
    set +e
Hubert Plociniczak cc9fdf
    $DAEMON start_all ${NODE_COUNT} > /var/log/rabbitmq/startup_log 2> /var/log/rabbitmq/startup_err
Hubert Plociniczak cc9fdf
    case "$?" in
Hubert Plociniczak cc9fdf
      0)
Hubert Plociniczak cc9fdf
        echo SUCCESS && touch $LOCK_FILE
Hubert Plociniczak cc9fdf
        RETVAL=0
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
      1)
Hubert Plociniczak cc9fdf
        echo TIMEOUT - check /var/log/rabbitmq/startup_\{log,err\}
Hubert Plociniczak cc9fdf
        RETVAL=1
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
      *)
Hubert Plociniczak cc9fdf
        echo FAILED - check /var/log/rabbitmq/startup_log, _err
Hubert Plociniczak cc9fdf
        RETVAL=1
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
    esac 
Hubert Plociniczak cc9fdf
    set -e
Hubert Plociniczak cc9fdf
}
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
stop_rabbitmq () {
Hubert Plociniczak cc9fdf
    set +e
Hubert Plociniczak cc9fdf
    status_rabbitmq quiet
Hubert Plociniczak cc9fdf
    if [ $RETVAL = 0 ] ; then
Hubert Plociniczak cc9fdf
        $DAEMON stop_all > /var/log/rabbitmq/shutdown_log 2> /var/log/rabbitmq/shutdown_err
Hubert Plociniczak cc9fdf
        RETVAL=$?
Hubert Plociniczak cc9fdf
        if [ $RETVAL != 0 ] ; then
Hubert Plociniczak cc9fdf
            echo FAILED - check /var/log/rabbitmq/shutdown_log, _err
Hubert Plociniczak cc9fdf
        else
Hubert Plociniczak cc9fdf
            rm -rf $LOCK_FILE
Hubert Plociniczak cc9fdf
        fi
Hubert Plociniczak cc9fdf
    else
Hubert Plociniczak cc9fdf
        echo No nodes running 
Hubert Plociniczak cc9fdf
        RETVAL=0
Hubert Plociniczak cc9fdf
    fi
Hubert Plociniczak cc9fdf
    set -e
Hubert Plociniczak cc9fdf
}
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
status_rabbitmq() {
Hubert Plociniczak cc9fdf
    set +e
Hubert Plociniczak cc9fdf
    if [ "$1" != "quiet" ] ; then
Hubert Plociniczak cc9fdf
        $DAEMON status 2>&1
Hubert Plociniczak cc9fdf
    else
Hubert Plociniczak cc9fdf
        $DAEMON status > /dev/null 2>&1
Hubert Plociniczak cc9fdf
    fi
Hubert Plociniczak cc9fdf
    if [ $? != 0 ] ; then
Hubert Plociniczak cc9fdf
        RETVAL=1
Hubert Plociniczak cc9fdf
    fi
Hubert Plociniczak cc9fdf
    set -e
Hubert Plociniczak cc9fdf
}
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
rotate_logs_rabbitmq() {
Hubert Plociniczak cc9fdf
    set +e
Hubert Plociniczak cc9fdf
    $DAEMON rotate_logs ${ROTATE_SUFFIX}
Hubert Plociniczak cc9fdf
    if [ $? != 0 ] ; then
Hubert Plociniczak cc9fdf
        RETVAL=1
Hubert Plociniczak cc9fdf
    fi
Hubert Plociniczak cc9fdf
    set -e
Hubert Plociniczak cc9fdf
}
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
restart_rabbitmq() {
Hubert Plociniczak cc9fdf
    stop_rabbitmq	    
Hubert Plociniczak cc9fdf
    start_rabbitmq
Hubert Plociniczak cc9fdf
}
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
case "$1" in
Hubert Plociniczak cc9fdf
    start)
Hubert Plociniczak cc9fdf
        echo -n "Starting $DESC: "
Hubert Plociniczak cc9fdf
        start_rabbitmq
Hubert Plociniczak cc9fdf
        echo "$NAME."
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
    stop)
Hubert Plociniczak cc9fdf
        echo -n "Stopping $DESC: "
Hubert Plociniczak cc9fdf
        stop_rabbitmq
Hubert Plociniczak cc9fdf
        echo "$NAME."
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
    status)
Hubert Plociniczak cc9fdf
        status_rabbitmq
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
    rotate-logs)
Hubert Plociniczak cc9fdf
        echo -n "Rotating log files for $DESC: "
Hubert Plociniczak cc9fdf
        rotate_logs_rabbitmq
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
    force-reload|reload|restart)
Hubert Plociniczak cc9fdf
        echo -n "Restarting $DESC: "
Hubert Plociniczak cc9fdf
        restart_rabbitmq
Hubert Plociniczak cc9fdf
        echo "$NAME."
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
    condrestart|try-restart)
Hubert Plociniczak cc9fdf
        echo -n "Restarting $DESC: "
Hubert Plociniczak cc9fdf
        restart_rabbitmq
Hubert Plociniczak cc9fdf
        echo "$NAME."
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
    *)
Hubert Plociniczak cc9fdf
        echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
Hubert Plociniczak cc9fdf
        RETVAL=2
Hubert Plociniczak cc9fdf
        ;;
Hubert Plociniczak cc9fdf
esac
Hubert Plociniczak cc9fdf
Hubert Plociniczak cc9fdf
exit $RETVAL