secret

rabbitmq init scripts

  • Download Gist
init script from rabbit 1.7.2
Groff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#
 
### BEGIN INIT INFO
# Provides: rabbitmq-server
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start:
# Default-Stop:
# Description: RabbitMQ broker
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
 
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DAEMON=/usr/sbin/rabbitmq-multi
NAME=rabbitmq-server
DESC=rabbitmq-server
USER=rabbitmq
NODE_COUNT=1
ROTATE_SUFFIX=
INIT_LOG_DIR=/var/log/rabbitmq
 
DEFAULTS_FILE=/etc/default/rabbitmq
LOCK_FILE=
 
test -x $DAEMON || exit 0
 
# Include rabbitmq defaults if available
if [ -f "$DEFAULTS_FILE" ] ; then
. $DEFAULTS_FILE
fi
 
RETVAL=0
set -e
 
start_rabbitmq () {
set +e
$DAEMON start_all ${NODE_COUNT} > ${INIT_LOG_DIR}/startup_log 2> ${INIT_LOG_DIR}/startup_err
case "$?" in
0)
echo SUCCESS
[ -n "$LOCK_FILE" ] && touch $LOCK_FILE
RETVAL=0
;;
1)
echo TIMEOUT - check ${INIT_LOG_DIR}/startup_\{log,err\}
RETVAL=1
;;
*)
echo FAILED - check ${INIT_LOG_DIR}/startup_log, _err
RETVAL=1
;;
esac
set -e
}
 
stop_rabbitmq () {
set +e
status_rabbitmq quiet
if [ $RETVAL = 0 ] ; then
$DAEMON stop_all > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
RETVAL=$?
if [ $RETVAL = 0 ] ; then
[ -n "$LOCK_FILE" ] && rm -rf $LOCK_FILE
else
echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err
fi
else
echo No nodes running
RETVAL=0
fi
set -e
}
 
status_rabbitmq() {
set +e
if [ "$1" != "quiet" ] ; then
$DAEMON status 2>&1
else
$DAEMON status > /dev/null 2>&1
fi
if [ $? != 0 ] ; then
RETVAL=1
fi
set -e
}
 
rotate_logs_rabbitmq() {
set +e
$DAEMON rotate_logs ${ROTATE_SUFFIX}
if [ $? != 0 ] ; then
RETVAL=1
fi
set -e
}
 
restart_rabbitmq() {
stop_rabbitmq
start_rabbitmq
}
 
case "$1" in
start)
echo -n "Starting $DESC: "
start_rabbitmq
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
stop_rabbitmq
echo "$NAME."
;;
status)
status_rabbitmq
;;
rotate-logs)
echo -n "Rotating log files for $DESC: "
rotate_logs_rabbitmq
;;
force-reload|reload|restart|condrestart|try-restart)
echo -n "Restarting $DESC: "
restart_rabbitmq
echo "$NAME."
;;
*)
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
RETVAL=1
;;
esac
 
exit $RETVAL
init script from rabbit 2.8.2
Groff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#
 
### BEGIN INIT INFO
# Provides: rabbitmq-server
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: RabbitMQ broker
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
 
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=rabbitmq-server
DAEMON=/usr/sbin/${NAME}
CONTROL=/usr/sbin/rabbitmqctl
DESC="message broker"
USER=rabbitmq
ROTATE_SUFFIX=
INIT_LOG_DIR=/var/log/rabbitmq
PID_FILE=/var/run/rabbitmq/pid
 
 
test -x $DAEMON || exit 0
test -x $CONTROL || exit 0
 
RETVAL=0
set -e
 
[ -f /etc/default/${NAME} ] && . /etc/default/${NAME}
 
. /lib/lsb/init-functions
. /lib/init/vars.sh
 
ensure_pid_dir () {
PID_DIR=`dirname ${PID_FILE}`
if [ ! -d ${PID_DIR} ] ; then
mkdir -p ${PID_DIR}
chown -R ${USER}:${USER} ${PID_DIR}
chmod 755 ${PID_DIR}
fi
}
 
remove_pid () {
rm -f ${PID_FILE}
rmdir `dirname ${PID_FILE}` || :
}
 
start_rabbitmq () {
status_rabbitmq quiet
if [ $RETVAL != 0 ] ; then
RETVAL=0
ensure_pid_dir
set +e
RABBITMQ_PID_FILE=$PID_FILE start-stop-daemon --quiet \
--chuid rabbitmq --start --exec $DAEMON \
--pidfile "$RABBITMQ_PID_FILE" \
> "${INIT_LOG_DIR}/startup_log" \
2> "${INIT_LOG_DIR}/startup_err" \
0<&- &
$CONTROL wait $PID_FILE >/dev/null 2>&1
RETVAL=$?
set -e
if [ $RETVAL != 0 ] ; then
remove_pid
fi
else
RETVAL=3
fi
}
 
stop_rabbitmq () {
status_rabbitmq quiet
if [ $RETVAL = 0 ] ; then
set +e
$CONTROL stop ${PID_FILE} > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
RETVAL=$?
set -e
if [ $RETVAL = 0 ] ; then
remove_pid
fi
else
RETVAL=3
fi
}
 
status_rabbitmq() {
set +e
if [ "$1" != "quiet" ] ; then
$CONTROL status 2>&1
else
$CONTROL status > /dev/null 2>&1
fi
if [ $? != 0 ] ; then
RETVAL=3
fi
set -e
}
 
rotate_logs_rabbitmq() {
set +e
$CONTROL -q rotate_logs ${ROTATE_SUFFIX}
if [ $? != 0 ] ; then
RETVAL=1
fi
set -e
}
 
restart_running_rabbitmq () {
status_rabbitmq quiet
if [ $RETVAL = 0 ] ; then
restart_rabbitmq
else
log_warning_msg "${DESC} not running"
fi
}
 
restart_rabbitmq() {
stop_rabbitmq
start_rabbitmq
}
 
restart_end() {
if [ $RETVAL = 0 ] ; then
log_end_msg 0
else
log_end_msg 1
fi
}
 
start_stop_end() {
case "$RETVAL" in
0)
log_end_msg 0;;
3)
log_warning_msg "${DESC} already ${1}"
log_end_msg 0;;
*)
log_warning_msg "FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}"
log_end_msg 1;;
esac
}
 
case "$1" in
start)
log_daemon_msg "Starting ${DESC}" $NAME
start_rabbitmq
start_stop_end "started"
;;
stop)
log_daemon_msg "Stopping ${DESC}" $NAME
stop_rabbitmq
start_stop_end "stopped"
;;
status)
status_rabbitmq
;;
rotate-logs)
log_action_begin_msg "Rotating log files for ${DESC} ${NAME}"
rotate_logs_rabbitmq
log_action_end_msg $RETVAL
;;
force-reload|reload|restart)
log_daemon_msg "Restarting ${DESC}" $NAME
restart_rabbitmq
restart_end
;;
try-restart)
log_daemon_msg "Restarting ${DESC}" $NAME
restart_running_rabbitmq
restart_end
;;
*)
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
RETVAL=1
;;
esac
 
exit $RETVAL

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.