diff options
author | David Wragg <david@rabbitmq.com> | 2011-09-06 20:16:59 +0100 |
---|---|---|
committer | David Wragg <david@rabbitmq.com> | 2011-09-06 20:16:59 +0100 |
commit | be4c3e380f6298756f3275b44fee08ef012d81f6 (patch) | |
tree | 76133e866068e49e21332800ebdd5fad92c3b879 | |
parent | dc2e200b1a75cac7531da2c3d95363e09e712226 (diff) | |
parent | 0bc4a145bde52f5d88541534b85a3985f0c087a8 (diff) | |
download | rabbitmq-server-be4c3e380f6298756f3275b44fee08ef012d81f6.tar.gz |
Merge bug24399 into default
init script assumes the existence of /var/run/rabbitmq
-rw-r--r-- | packaging/RPMS/Fedora/rabbitmq-server.spec | 2 | ||||
-rw-r--r-- | packaging/common/rabbitmq-server.init | 19 | ||||
-rwxr-xr-x | packaging/common/rabbitmq-server.ocf | 21 | ||||
-rw-r--r-- | packaging/debs/Debian/debian/dirs | 1 | ||||
-rw-r--r-- | packaging/debs/Debian/debian/postinst | 1 | ||||
-rw-r--r-- | packaging/debs/Debian/debian/postrm.in | 3 |
6 files changed, 35 insertions, 12 deletions
diff --git a/packaging/RPMS/Fedora/rabbitmq-server.spec b/packaging/RPMS/Fedora/rabbitmq-server.spec index f12cde0d..815b8cde 100644 --- a/packaging/RPMS/Fedora/rabbitmq-server.spec +++ b/packaging/RPMS/Fedora/rabbitmq-server.spec @@ -50,7 +50,6 @@ make install TARGET_DIR=%{_maindir} \ mkdir -p %{buildroot}%{_localstatedir}/lib/rabbitmq/mnesia mkdir -p %{buildroot}%{_localstatedir}/log/rabbitmq -mkdir -p %{buildroot}%{_localstatedir}/run/rabbitmq #Copy all necessary lib files etc. install -p -D -m 0755 %{S:1} %{buildroot}%{_initrddir}/rabbitmq-server @@ -112,7 +111,6 @@ done %defattr(-,root,root,-) %attr(0750, rabbitmq, rabbitmq) %dir %{_localstatedir}/lib/rabbitmq %attr(0750, rabbitmq, rabbitmq) %dir %{_localstatedir}/log/rabbitmq -%attr(0750, rabbitmq, rabbitmq) %dir %{_localstatedir}/run/rabbitmq %dir %{_sysconfdir}/rabbitmq %{_initrddir}/rabbitmq-server %config(noreplace) %{_sysconfdir}/logrotate.d/rabbitmq-server diff --git a/packaging/common/rabbitmq-server.init b/packaging/common/rabbitmq-server.init index e2815f04..15fd5d5b 100644 --- a/packaging/common/rabbitmq-server.init +++ b/packaging/common/rabbitmq-server.init @@ -34,12 +34,27 @@ test -x $CONTROL || exit 0 RETVAL=0 set -e +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 echo RabbitMQ is currently running else RETVAL=0 + ensure_pid_dir set +e setsid sh -c "RABBITMQ_PID_FILE=$PID_FILE $DAEMON > \ ${INIT_LOG_DIR}/startup_log 2> ${INIT_LOG_DIR}/startup_err" & @@ -54,7 +69,7 @@ start_rabbitmq () { fi ;; *) - rm -f $PID_FILE + remove_pid echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\} RETVAL=1 ;; @@ -70,7 +85,7 @@ stop_rabbitmq () { RETVAL=$? set -e if [ $RETVAL = 0 ] ; then - rm -f $PID_FILE + remove_pid if [ -n "$LOCK_FILE" ] ; then rm -f $LOCK_FILE fi diff --git a/packaging/common/rabbitmq-server.ocf b/packaging/common/rabbitmq-server.ocf index 9b27c644..e6776eff 100755 --- a/packaging/common/rabbitmq-server.ocf +++ b/packaging/common/rabbitmq-server.ocf @@ -179,6 +179,21 @@ RABBITMQ_PID_FILE=$OCF_RESKEY_pid_file [ ! -z $RABBITMQ_NODENAME ] && NODENAME_ARG="-n $RABBITMQ_NODENAME" [ ! -z $RABBITMQ_NODENAME ] && export RABBITMQ_NODENAME +ensure_pid_dir () { + PID_DIR=`dirname ${RABBITMQ_PID_FILE}` + if [ ! -d ${PID_DIR} ] ; then + mkdir -p ${PID_DIR} + chown -R rabbitmq:rabbitmq ${PID_DIR} + chmod 755 ${PID_DIR} + fi + return $OCF_SUCCESS +} + +remove_pid () { + rm -f ${RABBITMQ_PID_FILE} + rmdir `dirname ${RABBITMQ_PID_FILE}` || : +} + export_vars() { [ ! -z $RABBITMQ_NODE_IP_ADDRESS ] && export RABBITMQ_NODE_IP_ADDRESS [ ! -z $RABBITMQ_NODE_PORT ] && export RABBITMQ_NODE_PORT @@ -186,7 +201,7 @@ export_vars() { [ ! -z $RABBITMQ_LOG_BASE ] && export RABBITMQ_LOG_BASE [ ! -z $RABBITMQ_MNESIA_BASE ] && export RABBITMQ_MNESIA_BASE [ ! -z $RABBITMQ_SERVER_START_ARGS ] && export RABBITMQ_SERVER_START_ARGS - [ ! -z $RABBITMQ_PID_FILE ] && export RABBITMQ_PID_FILE + [ ! -z $RABBITMQ_PID_FILE ] && ensure_pid_dir && export RABBITMQ_PID_FILE } rabbit_validate_partial() { @@ -268,7 +283,7 @@ rabbit_start() { rabbit_wait $RABBITMQ_PID_FILE rc=$? if [ "$rc" != $OCF_SUCCESS ]; then - rm -f $RABBITMQ_PID_FILE + remove_pid ocf_log info "rabbitmq-server start failed: $rc" exit $OCF_ERR_GENERIC fi @@ -299,7 +314,7 @@ rabbit_stop() { rabbit_status rc=$? if [ "$rc" = $OCF_NOT_RUNNING ]; then - rm -f $RABBITMQ_PID_FILE + remove_pid stop_wait=0 break elif [ "$rc" != $OCF_SUCCESS ]; then diff --git a/packaging/debs/Debian/debian/dirs b/packaging/debs/Debian/debian/dirs index 5cf167d5..625b7d41 100644 --- a/packaging/debs/Debian/debian/dirs +++ b/packaging/debs/Debian/debian/dirs @@ -4,7 +4,6 @@ usr/sbin usr/share/man var/lib/rabbitmq/mnesia var/log/rabbitmq -var/run/rabbitmq etc/logrotate.d etc/rabbitmq diff --git a/packaging/debs/Debian/debian/postinst b/packaging/debs/Debian/debian/postinst index ca531f14..b11340ef 100644 --- a/packaging/debs/Debian/debian/postinst +++ b/packaging/debs/Debian/debian/postinst @@ -32,7 +32,6 @@ fi chown -R rabbitmq:rabbitmq /var/lib/rabbitmq chown -R rabbitmq:rabbitmq /var/log/rabbitmq -chown -R rabbitmq:rabbitmq /var/run/rabbitmq case "$1" in configure) diff --git a/packaging/debs/Debian/debian/postrm.in b/packaging/debs/Debian/debian/postrm.in index c4aeeebe..baf081fc 100644 --- a/packaging/debs/Debian/debian/postrm.in +++ b/packaging/debs/Debian/debian/postrm.in @@ -32,9 +32,6 @@ case "$1" in if [ -d /var/log/rabbitmq ]; then rm -r /var/log/rabbitmq fi - if [ -d /var/run/rabbitmq ]; then - rm -r /var/run/rabbitmq - fi if [ -d /etc/rabbitmq ]; then rm -r /etc/rabbitmq fi |