From f44ad9232cd39fa7aa0091ca4c94d453e72871a0 Mon Sep 17 00:00:00 2001 From: Peter Lemenkov Date: Nov 08 2011 09:17:38 +0000 Subject: Ver. 2.6.1 Signed-off-by: Peter Lemenkov --- diff --git a/.gitignore b/.gitignore index b2b6c43..bbfd013 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ rabbitmq-server-1.8.0.tar.gz /rabbitmq-server-2.1.1.tar.gz /rabbitmq-server-2.2.0.tar.gz /rabbitmq-server-2.6.0.tar.gz +/rabbitmq-server-2.6.1.tar.gz diff --git a/rabbitmq-script-wrapper b/rabbitmq-script-wrapper index e8d5d6f..5bb3269 100644 --- a/rabbitmq-script-wrapper +++ b/rabbitmq-script-wrapper @@ -1,33 +1,18 @@ #!/bin/sh -## The contents of this file are subject to the Mozilla Public License -## Version 1.1 (the "License"); you may not use this file except in -## compliance with the License. You may obtain a copy of the License at -## http://www.mozilla.org/MPL/ +## The contents of this file are subject to the Mozilla Public License +## Version 1.1 (the "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of the License +## at http://www.mozilla.org/MPL/ ## -## Software distributed under the License is distributed on an "AS IS" -## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -## License for the specific language governing rights and limitations -## under the License. +## Software distributed under the License is distributed on an "AS IS" +## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +## the License for the specific language governing rights and +## limitations under the License. ## -## The Original Code is RabbitMQ. +## The Original Code is RabbitMQ. ## -## The Initial Developers of the Original Code are LShift Ltd, -## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. -## -## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, -## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd -## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial -## Technologies LLC, and Rabbit Technologies Ltd. -## -## Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift -## Ltd. Portions created by Cohesive Financial Technologies LLC are -## Copyright (C) 2007-2010 Cohesive Financial Technologies -## LLC. Portions created by Rabbit Technologies Ltd are Copyright -## (C) 2007-2010 Rabbit Technologies Ltd. -## -## All Rights Reserved. -## -## Contributor(s): ______________________________________. +## The Initial Developer of the Original Code is VMware, Inc. +## Copyright (c) 2007-2011 VMware, Inc. All rights reserved. ## # Escape spaces and quotes, because shell is revolting. @@ -49,13 +34,9 @@ if [ `id -u` = 0 ] ; then elif [ `id -u` = `id -u rabbitmq` ] ; then /usr/lib/rabbitmq/bin/${SCRIPT} "$@" else - /usr/lib/rabbitmq/bin/${SCRIPT} "$@" - VAL=$? - if [ $VAL -gt 0 ] ; then - echo - echo "Only root or rabbitmq should run ${SCRIPT}" - echo - fi - exit $VAL + /usr/lib/rabbitmq/bin/${SCRIPT} + echo + echo "Only root or rabbitmq should run ${SCRIPT}" + echo + exit 1 fi - diff --git a/rabbitmq-server.init b/rabbitmq-server.init index 35fcd15..065e2a4 100644 --- a/rabbitmq-server.init +++ b/rabbitmq-server.init @@ -10,97 +10,111 @@ # 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 +DAEMON=/usr/sbin/${NAME} +CONTROL=/usr/sbin/rabbitmqctl DESC=rabbitmq-server USER=rabbitmq -NODE_COUNT=1 ROTATE_SUFFIX= INIT_LOG_DIR=/var/log/rabbitmq +PID_FILE=/var/run/rabbitmq/pid -DEFAULTS_FILE=/etc/sysconfig/rabbitmq LOCK_FILE=/var/lock/subsys/$NAME test -x $DAEMON || exit 0 - -# Include rabbitmq defaults if available -if [ -f "$DEFAULTS_FILE" ] ; then - . $DEFAULTS_FILE -fi +test -x $CONTROL || exit 0 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 + status_rabbitmq quiet + if [ $RETVAL = 0 ] ; then + echo RabbitMQ is currently running + else 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 + set +e + setsid sh -c "RABBITMQ_PID_FILE=$PID_FILE $DAEMON > \ + ${INIT_LOG_DIR}/startup_log 2> ${INIT_LOG_DIR}/startup_err" & + $CONTROL wait $PID_FILE >/dev/null 2>&1 + RETVAL=$? + set -e + case "$RETVAL" in + 0) + echo SUCCESS + if [ -n "$LOCK_FILE" ] ; then + touch $LOCK_FILE + fi + ;; + *) + rm -f $PID_FILE + echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\} + RETVAL=1 + ;; + esac + fi } 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 + set +e + $CONTROL stop > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err RETVAL=$? + set -e if [ $RETVAL = 0 ] ; then - [ -n "$LOCK_FILE" ] && rm -rf $LOCK_FILE + 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 - echo No nodes running + echo RabbitMQ is not running RETVAL=0 fi - set -e } status_rabbitmq() { set +e if [ "$1" != "quiet" ] ; then - $DAEMON status 2>&1 + $CONTROL status 2>&1 else - $DAEMON status > /dev/null 2>&1 + $CONTROL status > /dev/null 2>&1 fi if [ $? != 0 ] ; then - RETVAL=1 + RETVAL=3 fi set -e } rotate_logs_rabbitmq() { set +e - $DAEMON rotate_logs ${ROTATE_SUFFIX} + $CONTROL 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 + echo RabbitMQ is not runnning + RETVAL=0 + fi +} + restart_rabbitmq() { - stop_rabbitmq + stop_rabbitmq start_rabbitmq } @@ -122,11 +136,16 @@ case "$1" in echo -n "Rotating log files for $DESC: " rotate_logs_rabbitmq ;; - force-reload|reload|restart|condrestart|try-restart) + force-reload|reload|restart) echo -n "Restarting $DESC: " restart_rabbitmq echo "$NAME." ;; + try-restart) + echo -n "Restarting $DESC: " + restart_running_rabbitmq + echo "$NAME." + ;; *) echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2 RETVAL=1 diff --git a/rabbitmq-server.ocf b/rabbitmq-server.ocf index b969535..e6776ef 100755 --- a/rabbitmq-server.ocf +++ b/rabbitmq-server.ocf @@ -1,41 +1,26 @@ #!/bin/sh +## The contents of this file are subject to the Mozilla Public License +## Version 1.1 (the "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of the License +## at http://www.mozilla.org/MPL/ ## -## OCF Resource Agent compliant rabbitmq-server resource script. -## - -## The contents of this file are subject to the Mozilla Public License -## Version 1.1 (the "License"); you may not use this file except in -## compliance with the License. You may obtain a copy of the License at -## http://www.mozilla.org/MPL/ -## -## Software distributed under the License is distributed on an "AS IS" -## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -## License for the specific language governing rights and limitations -## under the License. -## -## The Original Code is RabbitMQ. +## Software distributed under the License is distributed on an "AS IS" +## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +## the License for the specific language governing rights and +## limitations under the License. ## -## The Initial Developers of the Original Code are LShift Ltd, -## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. +## The Original Code is RabbitMQ. ## -## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, -## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd -## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial -## Technologies LLC, and Rabbit Technologies Ltd. +## The Initial Developer of the Original Code is VMware, Inc. +## Copyright (c) 2007-2011 VMware, Inc. All rights reserved. ## -## Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift -## Ltd. Portions created by Cohesive Financial Technologies LLC are -## Copyright (C) 2007-2010 Cohesive Financial Technologies -## LLC. Portions created by Rabbit Technologies Ltd are Copyright -## (C) 2007-2010 Rabbit Technologies Ltd. -## -## All Rights Reserved. + ## -## Contributor(s): ______________________________________. +## OCF Resource Agent compliant rabbitmq-server resource script. ## ## OCF instance parameters -## OCF_RESKEY_multi +## OCF_RESKEY_server ## OCF_RESKEY_ctl ## OCF_RESKEY_nodename ## OCF_RESKEY_ip @@ -44,6 +29,7 @@ ## OCF_RESKEY_log_base ## OCF_RESKEY_mnesia_base ## OCF_RESKEY_server_start_args +## OCF_RESKEY_pid_file ####################################################################### # Initialization: @@ -53,14 +39,16 @@ ####################################################################### -OCF_RESKEY_multi_default="/usr/sbin/rabbitmq-multi" +OCF_RESKEY_server_default="/usr/sbin/rabbitmq-server" OCF_RESKEY_ctl_default="/usr/sbin/rabbitmqctl" OCF_RESKEY_nodename_default="rabbit@localhost" OCF_RESKEY_log_base_default="/var/log/rabbitmq" -: ${OCF_RESKEY_multi=${OCF_RESKEY_multi_default}} +OCF_RESKEY_pid_file_default="/var/run/rabbitmq/pid" +: ${OCF_RESKEY_server=${OCF_RESKEY_server_default}} : ${OCF_RESKEY_ctl=${OCF_RESKEY_ctl_default}} : ${OCF_RESKEY_nodename=${OCF_RESKEY_nodename_default}} : ${OCF_RESKEY_log_base=${OCF_RESKEY_log_base_default}} +: ${OCF_RESKEY_pid_file=${OCF_RESKEY_pid_file_default}} meta_data() { cat <Resource agent for RabbitMQ-server - + -The path to the rabbitmq-multi script +The path to the rabbitmq-server script -Path to rabbitmq-multi - +Path to rabbitmq-server + @@ -118,9 +106,9 @@ The IP Port for rabbitmq-server to listen on -Location of the config file +Location of the config file (without the .config suffix) -Config file path +Config file path (without the .config suffix) @@ -148,6 +136,14 @@ Additional arguments provided to the server on startup + + +Location of the file in which the pid will be stored + +Pid file path + + + @@ -170,7 +166,7 @@ Expects to have a fully populated OCF RA-compliant environment set. END } -RABBITMQ_MULTI=$OCF_RESKEY_multi +RABBITMQ_SERVER=$OCF_RESKEY_server RABBITMQ_CTL=$OCF_RESKEY_ctl RABBITMQ_NODENAME=$OCF_RESKEY_nodename RABBITMQ_NODE_IP_ADDRESS=$OCF_RESKEY_ip @@ -179,9 +175,25 @@ RABBITMQ_CONFIG_FILE=$OCF_RESKEY_config_file RABBITMQ_LOG_BASE=$OCF_RESKEY_log_base RABBITMQ_MNESIA_BASE=$OCF_RESKEY_mnesia_base RABBITMQ_SERVER_START_ARGS=$OCF_RESKEY_server_start_args +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 @@ -189,11 +201,12 @@ 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 ] && ensure_pid_dir && export RABBITMQ_PID_FILE } rabbit_validate_partial() { - if [ ! -x $RABBITMQ_MULTI ]; then - ocf_log err "rabbitmq-server multi $RABBITMQ_MULTI does not exist or is not executable"; + if [ ! -x $RABBITMQ_SERVER ]; then + ocf_log err "rabbitmq-server server $RABBITMQ_SERVER does not exist or is not executable"; exit $OCF_ERR_INSTALLED; fi @@ -204,8 +217,8 @@ rabbit_validate_partial() { } rabbit_validate_full() { - if [ ! -z $RABBITMQ_CONFIG_FILE ] && [ ! -e $RABBITMQ_CONFIG_FILE ]; then - ocf_log err "rabbitmq-server config_file $RABBITMQ_CONFIG_FILE does not exist or is not a file"; + if [ ! -z $RABBITMQ_CONFIG_FILE ] && [ ! -e "${RABBITMQ_CONFIG_FILE}.config" ]; then + ocf_log err "rabbitmq-server config_file ${RABBITMQ_CONFIG_FILE}.config does not exist or is not a file"; exit $OCF_ERR_INSTALLED; fi @@ -225,8 +238,18 @@ rabbit_validate_full() { } rabbit_status() { + rabbitmqctl_action "status" +} + +rabbit_wait() { + rabbitmqctl_action "wait" $1 +} + +rabbitmqctl_action() { local rc - $RABBITMQ_CTL $NODENAME_ARG status > /dev/null 2> /dev/null + local action + action=$@ + $RABBITMQ_CTL $NODENAME_ARG $action > /dev/null 2> /dev/null rc=$? case "$rc" in 0) @@ -238,7 +261,7 @@ rabbit_status() { return $OCF_NOT_RUNNING ;; *) - ocf_log err "Unexpected return from rabbitmqctl $NODENAME_ARG status: $rc" + ocf_log err "Unexpected return from rabbitmqctl $NODENAME_ARG $action: $rc" exit $OCF_ERR_GENERIC esac } @@ -253,28 +276,17 @@ rabbit_start() { export_vars - $RABBITMQ_MULTI start_all 1 > ${RABBITMQ_LOG_BASE}/startup_log 2> ${RABBITMQ_LOG_BASE}/startup_err & - rc=$? - - if [ "$rc" != 0 ]; then - ocf_log err "rabbitmq-server start command failed: $RABBITMQ_MULTI start_all 1, $rc" - return $rc - fi + setsid sh -c "$RABBITMQ_SERVER > ${RABBITMQ_LOG_BASE}/startup_log 2> ${RABBITMQ_LOG_BASE}/startup_err" & - # Spin waiting for the server to come up. + # Wait for the server to come up. # Let the CRM/LRM time us out if required - start_wait=1 - while [ $start_wait = 1 ]; do - rabbit_status - rc=$? - if [ "$rc" = $OCF_SUCCESS ]; then - start_wait=0 - elif [ "$rc" != $OCF_NOT_RUNNING ]; then - ocf_log info "rabbitmq-server start failed: $rc" - exit $OCF_ERR_GENERIC - fi - sleep 1 - done + rabbit_wait $RABBITMQ_PID_FILE + rc=$? + if [ "$rc" != $OCF_SUCCESS ]; then + remove_pid + ocf_log info "rabbitmq-server start failed: $rc" + exit $OCF_ERR_GENERIC + fi return $OCF_SUCCESS } @@ -287,11 +299,11 @@ rabbit_stop() { return $OCF_SUCCESS fi - $RABBITMQ_MULTI stop_all & + $RABBITMQ_CTL stop rc=$? if [ "$rc" != 0 ]; then - ocf_log err "rabbitmq-server stop command failed: $RABBITMQ_MULTI stop_all, $rc" + ocf_log err "rabbitmq-server stop command failed: $RABBITMQ_CTL stop, $rc" return $rc fi @@ -302,6 +314,7 @@ rabbit_stop() { rabbit_status rc=$? if [ "$rc" = $OCF_NOT_RUNNING ]; then + remove_pid stop_wait=0 break elif [ "$rc" != $OCF_SUCCESS ]; then diff --git a/rabbitmq-server.spec b/rabbitmq-server.spec index aa745ca..905b856 100644 --- a/rabbitmq-server.spec +++ b/rabbitmq-server.spec @@ -1,7 +1,7 @@ %define debug_package %{nil} Name: rabbitmq-server -Version: 2.6.0 +Version: 2.6.1 Release: 1%{?dist} License: MPLv1.1 Group: Development/Libraries @@ -10,6 +10,7 @@ Source1: rabbitmq-server.init Source2: rabbitmq-script-wrapper Source3: rabbitmq-server.logrotate Source4: rabbitmq-server.ocf +Source5: rabbitmq-server.tmpfiles URL: http://www.rabbitmq.com/ BuildArch: noarch BuildRequires: erlang >= R12B-3, python-simplejson, xmlto, libxslt, python @@ -56,7 +57,6 @@ mkdir -p %{buildroot}%{_localstatedir}/log/rabbitmq install -p -D -m 0755 %{S:1} %{buildroot}%{_initrddir}/rabbitmq-server install -p -D -m 0755 %{_rabbit_wrapper} %{buildroot}%{_sbindir}/rabbitmqctl install -p -D -m 0755 %{_rabbit_wrapper} %{buildroot}%{_sbindir}/rabbitmq-server -install -p -D -m 0755 %{_rabbit_wrapper} %{buildroot}%{_sbindir}/rabbitmq-multi install -p -D -m 0755 %{_rabbit_server_ocf} %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server install -p -D -m 0644 %{S:3} %{buildroot}%{_sysconfdir}/logrotate.d/rabbitmq-server @@ -73,6 +73,11 @@ echo '%defattr(-,root,root, -)' >> %{_builddir}/%{name}.files ! -regex '\.\(%{_rabbit_erllibdir}\|%{_rabbit_libdir}\).*' \ | sed -e 's/^\.//' >> %{_builddir}/%{name}.files) +install -d %{buildroot}%{_localstatedir}/run/rabbitmq +%if 0%{?fedora} > 14 +install -D -p -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf +%endif + %pre if [ $1 -gt 1 ]; then @@ -116,15 +121,23 @@ done %attr(0750, rabbitmq, rabbitmq) %dir %{_localstatedir}/log/rabbitmq %dir %{_sysconfdir}/rabbitmq %{_rabbit_erllibdir} -%{_rabbit_libdir} +%{_rabbit_libdir}/bin %{_initrddir}/rabbitmq-server %config(noreplace) %{_sysconfdir}/logrotate.d/rabbitmq-server +%if 0%{?fedora} > 14 +%config(noreplace) %{_sysconfdir}/tmpfiles.d/%{name}.conf +%endif +%dir %attr(755, rabbitmq, rabbitmq) %{_localstatedir}/run/rabbitmq %doc LICENSE LICENSE-MPL-RabbitMQ %clean rm -rf %{buildroot} %changelog +* Tue Nov 08 2011 Peter Lemenkov - 2.6.1-1 +- New Upstream Release - 2.6.1 +- Fixed rhbz #738067 (service cannot start - rabbitmq-multi missing) + * Mon Sep 12 2011 Peter Lemenkov - 2.6.0-1 - New Upstream Release - 2.6.0 diff --git a/rabbitmq-server.tmpfiles b/rabbitmq-server.tmpfiles new file mode 100644 index 0000000..c268182 --- /dev/null +++ b/rabbitmq-server.tmpfiles @@ -0,0 +1 @@ +D /var/run/rabbitmq 0755 rabbitmq rabbitmq - diff --git a/sources b/sources index 806cdf7..d2547a5 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -e4d9b6792b556f0c145cf02f1430f0b3 rabbitmq-server-2.6.0.tar.gz +c8b86f2e2a86502932b54e9ced2eb63c rabbitmq-server-2.6.1.tar.gz