From ba4a22848a15d0e4390c34f6dfe13a059b065c8a2bd9fe38ba5f763f64bd9398 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Wed, 5 Apr 2017 11:33:01 +0000 Subject: [PATCH] Accepting request 485761 from home:vuntz:branches:network:messaging:amqp - Stop shipping rabbitmq-server OCF resource agent as source file while it's included in the upstream tarball. Add patches for code that was specific to our variant; they now got upstreamed, but are not in this version of rabbitmq yet: pull-request-20.patch and pull-request-21.patch. - Also package the rabbitmq-server-ha OCF resource agent as it seems to be more appropriate for clustering. Add upstream fixes for making it more solid: pull-request-24.patch and pull-request-25.patch. - Ship an example of /etc/rabbitmq/rabbitmq-env.conf, as this is useful indication. It only contains commented examples, based on what the Debian package is doing. OBS-URL: https://build.opensuse.org/request/show/485761 OBS-URL: https://build.opensuse.org/package/show/network:messaging:amqp/rabbitmq-server?expand=0&rev=76 --- pull-request-20.patch | 50 ++++++ pull-request-21.patch | 196 ++++++++++++++++++++ pull-request-24.patch | 74 ++++++++ pull-request-25.patch | 36 ++++ rabbitmq-env.conf | 15 ++ rabbitmq-server.changes | 16 ++ rabbitmq-server.ocf | 390 ---------------------------------------- rabbitmq-server.spec | 22 ++- 8 files changed, 404 insertions(+), 395 deletions(-) create mode 100644 pull-request-20.patch create mode 100644 pull-request-21.patch create mode 100644 pull-request-24.patch create mode 100644 pull-request-25.patch create mode 100644 rabbitmq-env.conf delete mode 100644 rabbitmq-server.ocf diff --git a/pull-request-20.patch b/pull-request-20.patch new file mode 100644 index 0000000..153a87a --- /dev/null +++ b/pull-request-20.patch @@ -0,0 +1,50 @@ +From 6d9a00d54425b299c682af692c9fad413d9f5da4 Mon Sep 17 00:00:00 2001 +From: Vincent Untz +Date: Wed, 29 Mar 2017 21:44:32 +0200 +Subject: [PATCH 1/2] OCF RA: Use rabbitmqctl_action wrapper for stop action + +We want to use the wrapper function to call rabbitmqctl for stop, so +that we interpret correctly the exit code. +--- + scripts/rabbitmq-server.ocf | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/rabbitmq-server.ocf b/scripts/rabbitmq-server.ocf +index 804e654..284360b 100755 +--- a/scripts/rabbitmq-server.ocf ++++ b/scripts/rabbitmq-server.ocf +@@ -299,7 +299,7 @@ rabbit_stop() { + return $OCF_SUCCESS + fi + +- $RABBITMQ_CTL stop ${RABBITMQ_PID_FILE} ++ rabbitmqctl_action stop ${RABBITMQ_PID_FILE} + rc=$? + + if [ "$rc" != 0 ]; then + +From 3b9dcfc6653e7ae8e7ba9e2e738c9f7df30e5cce Mon Sep 17 00:00:00 2001 +From: Vincent Untz +Date: Wed, 29 Mar 2017 21:45:52 +0200 +Subject: [PATCH 2/2] OCF RA: accept 1 as valid exit code from "rabbitmqctl + status" + +It may return 1 if the server is not completely running yet, and we +don't want pacemaker to treat that as a complete unexpected error. +--- + scripts/rabbitmq-server.ocf | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/rabbitmq-server.ocf b/scripts/rabbitmq-server.ocf +index 284360b..bf8880d 100755 +--- a/scripts/rabbitmq-server.ocf ++++ b/scripts/rabbitmq-server.ocf +@@ -256,7 +256,7 @@ rabbitmqctl_action() { + ocf_log debug "RabbitMQ server is running normally" + return $OCF_SUCCESS + ;; +- 2) ++ 1|2) + ocf_log debug "RabbitMQ server is not running" + return $OCF_NOT_RUNNING + ;; diff --git a/pull-request-21.patch b/pull-request-21.patch new file mode 100644 index 0000000..afcf0a0 --- /dev/null +++ b/pull-request-21.patch @@ -0,0 +1,196 @@ +From 0a93dca147a5efbe7e5d6c6925873d7c99cfc1a7 Mon Sep 17 00:00:00 2001 +From: Alberto Planas +Date: Wed, 29 Mar 2017 22:10:53 +0200 +Subject: [PATCH 1/3] OCF RA: Add new limit_nofile parameter to rabbitmq-server + OCF RA + +This enables to change the limit of open files, as the default on +distributions is usually too low for rabbitmq. Default is 65535. +--- + scripts/rabbitmq-server.ocf | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/scripts/rabbitmq-server.ocf b/scripts/rabbitmq-server.ocf +index 804e654..7190d65 100755 +--- a/scripts/rabbitmq-server.ocf ++++ b/scripts/rabbitmq-server.ocf +@@ -30,6 +30,7 @@ + ## OCF_RESKEY_mnesia_base + ## OCF_RESKEY_server_start_args + ## OCF_RESKEY_pid_file ++## OCF_RESKEY_limit_nofile + + ####################################################################### + # Initialization: +@@ -44,11 +45,13 @@ OCF_RESKEY_ctl_default="/usr/sbin/rabbitmqctl" + OCF_RESKEY_nodename_default="rabbit@localhost" + OCF_RESKEY_log_base_default="/var/log/rabbitmq" + OCF_RESKEY_pid_file_default="/var/run/rabbitmq/pid" ++OCF_RESKEY_limit_nofile_default="65535" + : ${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}} ++: ${OCF_RESKEY_limit_nofile=${OCF_RESKEY_limit_nofile_default}} + + meta_data() { + cat < + + ++ ++ ++Soft and hard limit for NOFILE ++ ++NOFILE limit ++ ++ ++ + + + +@@ -176,6 +187,7 @@ 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 ++RABBITMQ_LIMIT_NOFILE=$OCF_RESKEY_limit_nofile + [ ! -z $RABBITMQ_NODENAME ] && NODENAME_ARG="-n $RABBITMQ_NODENAME" + [ ! -z $RABBITMQ_NODENAME ] && export RABBITMQ_NODENAME + +@@ -204,6 +216,10 @@ export_vars() { + [ ! -z $RABBITMQ_PID_FILE ] && ensure_pid_dir && export RABBITMQ_PID_FILE + } + ++set_limits() { ++ [ ! -z $RABBITMQ_LIMIT_NOFILE ] && ulimit -n $RABBITMQ_LIMIT_NOFILE ++} ++ + rabbit_validate_partial() { + if [ ! -x $RABBITMQ_SERVER ]; then + ocf_log err "rabbitmq-server server $RABBITMQ_SERVER does not exist or is not executable"; +@@ -276,6 +292,9 @@ rabbit_start() { + + export_vars + ++ # RabbitMQ requires high soft and hard limits for NOFILE ++ set_limits ++ + setsid sh -c "$RABBITMQ_SERVER > ${RABBITMQ_LOG_BASE}/startup_log 2> ${RABBITMQ_LOG_BASE}/startup_err" & + + # Wait for the server to come up. + +From 89d65b51aa7232207c29dd3010d669d4b54901f4 Mon Sep 17 00:00:00 2001 +From: Vincent Untz +Date: Wed, 29 Mar 2017 22:20:25 +0200 +Subject: [PATCH 2/3] OCF RA: Add new limit_nofile parameter to + rabbitmq-server-ha OCF RA + +This enables to change the limit of open files, as the default on +distributions is usually too low for rabbitmq. Default is 65535. +--- + scripts/rabbitmq-server-ha.ocf | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/scripts/rabbitmq-server-ha.ocf b/scripts/rabbitmq-server-ha.ocf +index 49f3af7..2d5d660 100755 +--- a/scripts/rabbitmq-server-ha.ocf ++++ b/scripts/rabbitmq-server-ha.ocf +@@ -50,6 +50,7 @@ OCF_RESKEY_max_rabbitmqctl_timeouts_default=3 + OCF_RESKEY_policy_file_default="/usr/local/sbin/set_rabbitmq_policy" + OCF_RESKEY_rmq_feature_health_check_default=true + OCF_RESKEY_rmq_feature_local_list_queues_default=true ++OCF_RESKEY_limit_nofile_default=65535 + + : ${HA_LOGTAG="lrmd"} + : ${HA_LOGFACILITY="daemon"} +@@ -74,6 +75,7 @@ OCF_RESKEY_rmq_feature_local_list_queues_default=true + : ${OCF_RESKEY_policy_file=${OCF_RESKEY_policy_file_default}} + : ${OCF_RESKEY_rmq_feature_health_check=${OCF_RESKEY_rmq_feature_health_check_default}} + : ${OCF_RESKEY_rmq_feature_local_list_queues=${OCF_RESKEY_rmq_feature_local_list_queues_default}} ++: ${OCF_RESKEY_limit_nofile=${OCF_RESKEY_limit_nofile_default}} + + ####################################################################### + +@@ -332,6 +334,14 @@ stopped/demoted. + + + ++ ++ ++Soft and hard limit for NOFILE ++ ++NOFILE limit ++ ++ ++ + $EXTENDED_OCF_PARAMS + + +@@ -556,6 +566,10 @@ now() { + date -u +%s + } + ++set_limits() { ++ [ ! -z $OCF_RESKEY_limit_nofile ] && ulimit -n $OCF_RESKEY_limit_nofile ++} ++ + master_score() { + local LH="${LL} master_score():" + local score=$1 +@@ -1166,6 +1180,9 @@ start_beam_process() { + + [ -f /etc/default/rabbitmq-server ] && . /etc/default/rabbitmq-server + ++ # RabbitMQ requires high soft and hard limits for NOFILE ++ set_limits ++ + # run beam process + command="${OCF_RESKEY_binary} >> \"${OCF_RESKEY_log_dir}/startup_log\" 2>/dev/null" + RABBITMQ_NODE_ONLY=1 su rabbitmq -s /bin/sh -c "${command}"& + +From 73080ac78348916635e45c2f62aa7d86c0765b42 Mon Sep 17 00:00:00 2001 +From: Vincent Untz +Date: Tue, 4 Apr 2017 15:13:52 +0200 +Subject: [PATCH 3/3] OCF RA: Only set limit for open files when higher than + current value + +This allows to set the limit via some other way. +--- + scripts/rabbitmq-server-ha.ocf | 5 ++++- + scripts/rabbitmq-server.ocf | 5 ++++- + 2 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/scripts/rabbitmq-server-ha.ocf b/scripts/rabbitmq-server-ha.ocf +index 2d5d660..ea07916 100755 +--- a/scripts/rabbitmq-server-ha.ocf ++++ b/scripts/rabbitmq-server-ha.ocf +@@ -567,7 +567,10 @@ now() { + } + + set_limits() { +- [ ! -z $OCF_RESKEY_limit_nofile ] && ulimit -n $OCF_RESKEY_limit_nofile ++ local current_limit=$(su $OCF_RESKEY_username -s /bin/sh -c "ulimit -n") ++ if [ ! -z $OCF_RESKEY_limit_nofile -a $OCF_RESKEY_limit_nofile -gt $current_limit ] ; then ++ ulimit -n $OCF_RESKEY_limit_nofile ++ fi + } + + master_score() { +diff --git a/scripts/rabbitmq-server.ocf b/scripts/rabbitmq-server.ocf +index 7190d65..dbca06f 100755 +--- a/scripts/rabbitmq-server.ocf ++++ b/scripts/rabbitmq-server.ocf +@@ -217,7 +217,10 @@ export_vars() { + } + + set_limits() { +- [ ! -z $RABBITMQ_LIMIT_NOFILE ] && ulimit -n $RABBITMQ_LIMIT_NOFILE ++ local current_limit=$(su rabbitmq -s /bin/sh -c "ulimit -n") ++ if [ ! -z $RABBITMQ_LIMIT_NOFILE -a $RABBITMQ_LIMIT_NOFILE -gt $current_limit ] ; then ++ ulimit -n $RABBITMQ_LIMIT_NOFILE ++ fi + } + + rabbit_validate_partial() { diff --git a/pull-request-24.patch b/pull-request-24.patch new file mode 100644 index 0000000..07f8bf4 --- /dev/null +++ b/pull-request-24.patch @@ -0,0 +1,74 @@ +From 525eaba13a395550b0711751c16732197ff4dc9e Mon Sep 17 00:00:00 2001 +From: Vincent Untz +Date: Fri, 31 Mar 2017 13:05:51 +0200 +Subject: [PATCH] OCF RA: Add default_vhost parameter to rabbitmq-server-ha.ocf + +This enables the cluster to focus on a vhost that is not /, in case the +most important vhost is something else. + +For reference, other vhosts may exist in the cluster, but these are not +guaranteed to not suffer from any data loss. This patch doesn't address +this issue. + +Closes https://github.com/rabbitmq/rabbitmq-server-release/issues/22 +--- + scripts/rabbitmq-server-ha.ocf | 18 ++++++++++++++++-- + 1 file changed, 16 insertions(+), 2 deletions(-) + +diff --git a/scripts/rabbitmq-server-ha.ocf b/scripts/rabbitmq-server-ha.ocf +index 49f3af7..c5c2ebf 100755 +--- a/scripts/rabbitmq-server-ha.ocf ++++ b/scripts/rabbitmq-server-ha.ocf +@@ -42,6 +42,7 @@ OCF_RESKEY_mnesia_base_default="/var/lib/rabbitmq/mnesia" + OCF_RESKEY_mnesia_schema_base_default="/var/lib/rabbitmq" + OCF_RESKEY_host_ip_default="127.0.0.1" + OCF_RESKEY_node_port_default=5672 ++OCF_RESKEY_default_vhost_default="/" + OCF_RESKEY_erlang_cookie_default=false + OCF_RESKEY_erlang_cookie_file_default="/var/lib/rabbitmq/.erlang.cookie" + OCF_RESKEY_use_fqdn_default=false +@@ -67,6 +68,7 @@ OCF_RESKEY_rmq_feature_local_list_queues_default=true + : ${OCF_RESKEY_mnesia_schema_base=${OCF_RESKEY_mnesia_schema_base_default}} + : ${OCF_RESKEY_pid_file=${OCF_RESKEY_pid_file_default}} + : ${OCF_RESKEY_node_port=${OCF_RESKEY_node_port_default}} ++: ${OCF_RESKEY_default_vhost=${OCF_RESKEY_default_vhost_default}} + : ${OCF_RESKEY_erlang_cookie=${OCF_RESKEY_erlang_cookie_default}} + : ${OCF_RESKEY_erlang_cookie_file=${OCF_RESKEY_erlang_cookie_file_default}} + : ${OCF_RESKEY_use_fqdn=${OCF_RESKEY_use_fqdn_default}} +@@ -262,6 +264,18 @@ ${OCF_RESKEY_binary} should listen on this port + + + ++ ++ ++Default virtual host used for monitoring if a node is fully synchronized with ++the rest of the cluster. In normal operation, the resource agent will wait for ++queues from this virtual host on this node to be synchronized elsewhere before ++stopping RabbitMQ. This also means queues in other virtual hosts may not be ++fully synchronized on stop operations. ++ ++Default virtual host used for waiting for synchronization ++ ++ ++ + + + Erlang cookie for clustering. If specified, will be updated at the mnesia reset +@@ -1491,7 +1505,7 @@ wait_sync() { + opt_arg="--local" + fi + +- queues="${COMMAND_TIMEOUT} ${OCF_RESKEY_ctl} list_queues $opt_arg name state" ++ queues="${COMMAND_TIMEOUT} ${OCF_RESKEY_ctl} -p ${OCF_RESKEY_default_vhost} list_queues $opt_arg name state" + + su_rabbit_cmd -t "${wait_time}" "sh -c \"while ${queues} | grep -q 'syncing,'; \ + do sleep 2; done\"" +@@ -1793,7 +1807,7 @@ node_health_check_legacy() { + local queues + local rc_queues + local timeout_queues +- queues=`su_rabbit_cmd "${OCF_RESKEY_ctl} -q list_queues memory messages consumer_utilisation"` ++ queues=`su_rabbit_cmd "${OCF_RESKEY_ctl} -q -p ${OCF_RESKEY_default_vhost} list_queues memory messages consumer_utilisation"` + rc_queues=$? + check_timeouts $rc_queues "rabbit_list_queues_timeouts" "list_queues" + timeout_queues=$? diff --git a/pull-request-25.patch b/pull-request-25.patch new file mode 100644 index 0000000..3274fc8 --- /dev/null +++ b/pull-request-25.patch @@ -0,0 +1,36 @@ +From 9bd1b0a5f3e421823aaf7ef243ebe9c5d30b7855 Mon Sep 17 00:00:00 2001 +From: Vincent Untz +Date: Fri, 31 Mar 2017 13:23:00 +0200 +Subject: [PATCH] OCF RA: Don't hardcode primitive name in + rabbitmq-server-ha.ocf + +We can compute the name of the primitive automatically from environment +variables, instead of hard-coding p_rabbitmq-server; this makes the +resource agent more flexible. + +Closes https://github.com/rabbitmq/rabbitmq-server-release/issues/23 +--- + scripts/rabbitmq-server-ha.ocf | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/scripts/rabbitmq-server-ha.ocf b/scripts/rabbitmq-server-ha.ocf +index 49f3af7..81fe19b 100755 +--- a/scripts/rabbitmq-server-ha.ocf ++++ b/scripts/rabbitmq-server-ha.ocf +@@ -89,6 +89,7 @@ OCF_RESKEY_command_timeout_default="" + : ${OCF_RESKEY_command_timeout=${OCF_RESKEY_command_timeout_default}} + TIMEOUT_ARG=$((OCF_RESKEY_CRM_meta_timeout / 6000 + 30)) + COMMAND_TIMEOUT="/usr/bin/timeout ${OCF_RESKEY_command_timeout} ${TIMEOUT_ARG}" ++RESOURCE_NAME=`echo $OCF_RESOURCE_INSTANCE | cut -d ":" -f 1` + + ####################################################################### + +@@ -654,7 +655,7 @@ get_node_start_time() { + } + + get_node_master_score() { +- get_integer_node_attr $1 'master-p_rabbitmq-server' ++ get_integer_node_attr $1 "master-${RESOURCE_NAME}" + } + + # Return either rabbit node name as FQDN or shortname, depends on the OCF_RESKEY_use_fqdn. diff --git a/rabbitmq-env.conf b/rabbitmq-env.conf new file mode 100644 index 0000000..da8357c --- /dev/null +++ b/rabbitmq-env.conf @@ -0,0 +1,15 @@ +# See man rabbitmq-env.conf(5) for documentation + +# Defaults to rabbit. This can be useful if you want to run more than one node +# per machine - RABBITMQ_NODENAME should be unique per erlang-node-and-machine +# combination. See the clustering on a single machine guide for details: +# http://www.rabbitmq.com/clustering.html#single-machine +#NODENAME=rabbit + +# By default RabbitMQ will bind to all interfaces, on IPv4 and IPv6 if +# available. Set this if you only want to bind to one network interface or# +# address family. +#NODE_IP_ADDRESS=127.0.0.1 + +# Defaults to 5672. +#NODE_PORT=5672 diff --git a/rabbitmq-server.changes b/rabbitmq-server.changes index 9ddd7a3..73d9a95 100644 --- a/rabbitmq-server.changes +++ b/rabbitmq-server.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Wed Apr 5 08:16:09 UTC 2017 - vuntz@suse.com + +- Stop shipping rabbitmq-server OCF resource agent as source file + while it's included in the upstream tarball. Add patches for code + that was specific to our variant; they now got upstreamed, but + are not in this version of rabbitmq yet: pull-request-20.patch + and pull-request-21.patch. +- Also package the rabbitmq-server-ha OCF resource agent as it + seems to be more appropriate for clustering. Add upstream fixes + for making it more solid: pull-request-24.patch and + pull-request-25.patch. +- Ship an example of /etc/rabbitmq/rabbitmq-env.conf, as this is + useful indication. It only contains commented examples, based on + what the Debian package is doing. + ------------------------------------------------------------------- Wed Feb 15 13:09:26 UTC 2017 - mrueckert@suse.de diff --git a/rabbitmq-server.ocf b/rabbitmq-server.ocf deleted file mode 100644 index af04598..0000000 --- a/rabbitmq-server.ocf +++ /dev/null @@ -1,390 +0,0 @@ -#!/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/ -## -## 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 Initial Developer of the Original Code is VMware, Inc. -## Copyright (c) 2007-2012 VMware, Inc. All rights reserved. -## - -## -## OCF Resource Agent compliant rabbitmq-server resource script. -## - -## OCF instance parameters -## OCF_RESKEY_server -## OCF_RESKEY_ctl -## OCF_RESKEY_nodename -## OCF_RESKEY_ip -## OCF_RESKEY_port -## OCF_RESKEY_config_file -## OCF_RESKEY_log_base -## OCF_RESKEY_mnesia_base -## OCF_RESKEY_server_start_args -## OCF_RESKEY_pid_file -## OCF_RESKEY_limit_nofile - -####################################################################### -# Initialization: - -: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat} -. ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs - -####################################################################### - -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_pid_file_default="/var/run/rabbitmq/pid" -OCF_RESKEY_limit_nofile_default="65535" -: ${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}} -: ${OCF_RESKEY_limit_nofile=${OCF_RESKEY_limit_nofile_default}} - -meta_data() { - cat < - - -1.0 - - -Resource agent for RabbitMQ-server - - -Resource agent for RabbitMQ-server - - - - -The path to the rabbitmq-server script - -Path to rabbitmq-server - - - - - -The path to the rabbitmqctl script - -Path to rabbitmqctl - - - - - -The node name for rabbitmq-server - -Node name - - - - - -The IP address for rabbitmq-server to listen on - -IP Address - - - - - -The IP Port for rabbitmq-server to listen on - -IP Port - - - - - -Location of the config file (without the .config suffix) - -Config file path (without the .config suffix) - - - - - -Location of the directory under which logs will be created - -Log base path - - - - - -Location of the directory under which mnesia will store data - -Mnesia base path - - - - - -Additional arguments provided to the server on startup - -Server start arguments - - - - - -Location of the file in which the pid will be stored - -Pid file path - - - - - -Soft and hard limit for NOFILE - -NOFILE limit - - - - - - - - - - - - - - -END -} - -rabbit_usage() { - cat < /dev/null 2> /dev/null - rc=$? - case "$rc" in - 0) - ocf_log debug "RabbitMQ server is running normally" - return $OCF_SUCCESS - ;; - 1|2) - ocf_log debug "RabbitMQ server is not running" - return $OCF_NOT_RUNNING - ;; - *) - ocf_log err "Unexpected return from rabbitmqctl $NODENAME_ARG $action: $rc" - exit $OCF_ERR_GENERIC - esac -} - -rabbit_start() { - local rc - - if rabbit_status; then - ocf_log info "Resource already running." - return $OCF_SUCCESS - fi - - export_vars - - # RabbitMQ requires high soft and hard limits for NOFILE - set_limits - - setsid sh -c "$RABBITMQ_SERVER > ${RABBITMQ_LOG_BASE}/startup_log 2> ${RABBITMQ_LOG_BASE}/startup_err" & - - # Wait for the server to come up. - # Let the CRM/LRM time us out if required - 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 -} - -rabbit_stop() { - local rc - - if ! rabbit_status; then - ocf_log info "Resource not running." - return $OCF_SUCCESS - fi - - rabbitmqctl_action stop - rc=$? - - if [ "$rc" != 0 ]; then - ocf_log err "rabbitmq-server stop command failed: $RABBITMQ_CTL stop, $rc" - return $rc - fi - - # Spin waiting for the server to shut down. - # Let the CRM/LRM time us out if required - stop_wait=1 - while [ $stop_wait = 1 ]; do - rabbit_status - rc=$? - if [ "$rc" = $OCF_NOT_RUNNING ]; then - remove_pid - stop_wait=0 - break - elif [ "$rc" != $OCF_SUCCESS ]; then - ocf_log info "rabbitmq-server stop failed: $rc" - exit $OCF_ERR_GENERIC - fi - sleep 1 - done - - return $OCF_SUCCESS -} - -rabbit_monitor() { - rabbit_status - return $? -} - -case $__OCF_ACTION in - meta-data) - meta_data - exit $OCF_SUCCESS - ;; - usage|help) - rabbit_usage - exit $OCF_SUCCESS - ;; -esac - -if ocf_is_probe; then - rabbit_validate_partial -else - rabbit_validate_full -fi - -case $__OCF_ACTION in - start) - rabbit_start - ;; - stop) - rabbit_stop - ;; - status|monitor) - rabbit_monitor - ;; - validate-all) - exit $OCF_SUCCESS - ;; - *) - rabbit_usage - exit $OCF_ERR_UNIMPLEMENTED - ;; -esac - -exit $? diff --git a/rabbitmq-server.spec b/rabbitmq-server.spec index bf31d78..78c06bf 100644 --- a/rabbitmq-server.spec +++ b/rabbitmq-server.spec @@ -15,6 +15,7 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # + %bcond_without split_plugins %define _rabbit_erllibdir %{_libdir}/rabbitmq/lib/rabbitmq_server-%{version} @@ -38,12 +39,20 @@ Source1: rabbitmq-server.init # This comes from: http://hg.rabbitmq.com/rabbitmq-server/raw-file/2da625c0a436/packaging/common/rabbitmq-script-wrapper Source2: rabbitmq-script-wrapper Source3: rabbitmq-server.logrotate -Source4: rabbitmq-server.ocf +Source4: rabbitmq-env.conf Source5: rabbitmq-server.sysconfig Source6: rabbitmq-server.service Source7: rabbitmq-server.tmpfiles.d.conf Source8: README.SUSE Source9: rabbitmq.config.example +# PATCH-FIX-UPSTREAM pull-request-20.patch https://github.com/rabbitmq/rabbitmq-server-release/pull/20 -- minor fixes to rabbitmq-server.ocf +Patch0: pull-request-20.patch +# PATCH-FIX-UPSTREAM pull-request-21.patch https://github.com/rabbitmq/rabbitmq-server-release/pull/21 -- ulimit improvements for ocf files +Patch1: pull-request-21.patch +# PATCH-FIX-UPSTREAM pull-request-24.patch https://github.com/rabbitmq/rabbitmq-server-release/pull/24 -- allow specifying vhost to use in rabbitmq-server-ha.ocf +Patch2: pull-request-24.patch +# PATCH-FIX-UPSTREAM pull-request-25.patch https://github.com/rabbitmq/rabbitmq-server-release/pull/25 -- fix rabbitmq-server-ha.ocf to not hardcode resource name +Patch3: pull-request-25.patch BuildRequires: erlang BuildRequires: erlang-src BuildRequires: fdupes @@ -108,10 +117,11 @@ This package includes the RabbitMQ AMQP language bindings for Erlang. %prep %setup -q -%define _rabbit_server_ocf `basename %{SOURCE4}` -cp %{SOURCE4} %{_rabbit_server_ocf} cp %{SOURCE8} . -#patch10 -p1 +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 %build make all %{_make_args} %{?_smp_mflags} @@ -140,10 +150,12 @@ sed -i 's|@RABBITMQ_ROOT@|%{_rabbit_erllibdir}/|' %{_rabbit_wrapper} 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-plugins -install -p -D -m 0755 %{_rabbit_server_ocf} %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server +install -p -D -m 0755 scripts/rabbitmq-server.ocf %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server +install -p -D -m 0755 scripts/rabbitmq-server-ha.ocf %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server-ha # install config files install -p -D -m 0644 %{SOURCE9} %{buildroot}/%{_sysconfdir}/rabbitmq/rabbitmq.config +install -p -D -m 0644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/rabbitmq/rabbitmq-env.conf # Copy all necessary lib files etc. install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/rabbitmq-server