rabbitmq-server/rabbitmq-server.init
Marcus Rueckert 5843c59cf0 Accepting request 455065 from devel:languages:erlang
- IMPORTANT CHANGE
  Require the epmd service instead of running our own version as
  rabbitmq user.
  This requires that you configure epmd to listen on more
  interfaces than just 127.0.0.1.
  For non systemd based distributions you can set EPMD_ADDRESSES in
  /etc/sysconfing/erlang.
  For systemd based distributions please follow
  /usr/share/doc/packages/erlang/README.SUSE
  IMPORTANT CHANGE
  This change is also documented in
  /usr/share/doc/packages/rabbitmq-server/README.SUSE

OBS-URL: https://build.opensuse.org/request/show/455065
OBS-URL: https://build.opensuse.org/package/show/network:messaging:amqp/rabbitmq-server?expand=0&rev=71
2017-02-06 16:06:05 +00:00

166 lines
3.6 KiB
Bash

#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#
### BEGIN INIT INFO
# Provides: rabbitmq-server
# Required-Start: $local_fs $network $remote_fs epmd
# Required-Stop: $local_fs $network $remote_fs epmd
# 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
# Source function library
. /etc/rc.status
rc_reset
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
chown rabbitmq. /var/run/rabbitmq
start_rabbitmq () {
status_rabbitmq quiet
if [ $? -eq 0 ] ; then
return 0
else
export RABBITMQ_PID_FILE=$PID_FILE
startproc -l ${INIT_LOG_DIR}/startup_log -p $PID_FILE $DAEMON
$CONTROL wait $PID_FILE >/dev/null 2>&1
rc=$?
case "$rc" in
0)
if [ -n "$LOCK_FILE" ] ; then
touch $LOCK_FILE
fi
;;
*)
rm -f $PID_FILE
echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}
rc=1
;;
esac
fi
return $rc
}
stop_rabbitmq () {
status_rabbitmq quiet
if [ $? -eq 0 ] ; then
$CONTROL stop > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
rc=$?
if [ $rc -eq 0 ] ; then
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
rc=0
fi
return $rc
}
status_rabbitmq() {
rc=0
if [ "$1" != "quiet" ] ; then
$CONTROL status 2>&1
else
$CONTROL status > /dev/null 2>&1
fi
if [ $? -ne 0 ] ; then
rc=3
fi
return $rc
}
rotate_logs_rabbitmq() {
rc=0
$CONTROL rotate_logs ${ROTATE_SUFFIX}
if [ $? != 0 ] ; then
rc=1
fi
return $rc
}
restart_running_rabbitmq () {
status_rabbitmq quiet
if [ $? -eq 0 ] ; then
restart_rabbitmq
else
echo RabbitMQ is not runnning
fi
}
restart_rabbitmq() {
$0 stop
$0 start
}
case "$1" in
start)
echo -n "Starting $DESC: "
start_rabbitmq
rc_status -v
;;
stop)
echo -n "Stopping $DESC: "
stop_rabbitmq
rc_status -v
;;
status)
status_rabbitmq
rc_status # no verbose here -- status function already prints status out
;;
rotate-logs)
echo -n "Rotating log files for $DESC: "
rotate_logs_rabbitmq
rc_status
;;
force-reload|reload|restart)
restart_rabbitmq
rc_status
;;
condrestart|try-restart)
restart_running_rabbitmq
rc_status
;;
*)
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
exit 1
;;
esac
rc_exit