|
Hubert Plociniczak |
7d96b2 |
#!/bin/sh
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
## OCF Resource Agent compliant rabbitmq-server resource script.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
## The contents of this file are subject to the Mozilla Public License
|
|
Hubert Plociniczak |
7d96b2 |
## Version 1.1 (the "License"); you may not use this file except in
|
|
Hubert Plociniczak |
7d96b2 |
## compliance with the License. You may obtain a copy of the License at
|
|
Hubert Plociniczak |
7d96b2 |
## http://www.mozilla.org/MPL/
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
## Software distributed under the License is distributed on an "AS IS"
|
|
Hubert Plociniczak |
7d96b2 |
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
Hubert Plociniczak |
7d96b2 |
## License for the specific language governing rights and limitations
|
|
Hubert Plociniczak |
7d96b2 |
## under the License.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
## The Original Code is RabbitMQ.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
## The Initial Developers of the Original Code are LShift Ltd,
|
|
Hubert Plociniczak |
7d96b2 |
## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
|
|
Hubert Plociniczak |
7d96b2 |
## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
|
|
Hubert Plociniczak |
7d96b2 |
## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
|
|
Hubert Plociniczak |
7d96b2 |
## Technologies LLC, and Rabbit Technologies Ltd.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
## Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
|
|
Hubert Plociniczak |
7d96b2 |
## Ltd. Portions created by Cohesive Financial Technologies LLC are
|
|
Hubert Plociniczak |
7d96b2 |
## Copyright (C) 2007-2010 Cohesive Financial Technologies
|
|
Hubert Plociniczak |
7d96b2 |
## LLC. Portions created by Rabbit Technologies Ltd are Copyright
|
|
Hubert Plociniczak |
7d96b2 |
## (C) 2007-2010 Rabbit Technologies Ltd.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
## All Rights Reserved.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
## Contributor(s): ______________________________________.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
## OCF instance parameters
|
|
Hubert Plociniczak |
7d96b2 |
## OCF_RESKEY_multi
|
|
Hubert Plociniczak |
7d96b2 |
## OCF_RESKEY_ctl
|
|
Hubert Plociniczak |
7d96b2 |
## OCF_RESKEY_nodename
|
|
Hubert Plociniczak |
7d96b2 |
## OCF_RESKEY_ip
|
|
Hubert Plociniczak |
7d96b2 |
## OCF_RESKEY_port
|
|
Hubert Plociniczak |
7d96b2 |
## OCF_RESKEY_config_file
|
|
Hubert Plociniczak |
7d96b2 |
## OCF_RESKEY_log_base
|
|
Hubert Plociniczak |
7d96b2 |
## OCF_RESKEY_mnesia_base
|
|
Hubert Plociniczak |
7d96b2 |
## OCF_RESKEY_server_start_args
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
#######################################################################
|
|
Hubert Plociniczak |
7d96b2 |
# Initialization:
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
|
|
Hubert Plociniczak |
7d96b2 |
. ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
#######################################################################
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
OCF_RESKEY_multi_default="/usr/sbin/rabbitmq-multi"
|
|
Hubert Plociniczak |
7d96b2 |
OCF_RESKEY_ctl_default="/usr/sbin/rabbitmqctl"
|
|
Hubert Plociniczak |
7d96b2 |
OCF_RESKEY_nodename_default="rabbit@localhost"
|
|
Hubert Plociniczak |
7d96b2 |
OCF_RESKEY_log_base_default="/var/log/rabbitmq"
|
|
Hubert Plociniczak |
7d96b2 |
: ${OCF_RESKEY_multi=${OCF_RESKEY_multi_default}}
|
|
Hubert Plociniczak |
7d96b2 |
: ${OCF_RESKEY_ctl=${OCF_RESKEY_ctl_default}}
|
|
Hubert Plociniczak |
7d96b2 |
: ${OCF_RESKEY_nodename=${OCF_RESKEY_nodename_default}}
|
|
Hubert Plociniczak |
7d96b2 |
: ${OCF_RESKEY_log_base=${OCF_RESKEY_log_base_default}}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
meta_data() {
|
|
Hubert Plociniczak |
7d96b2 |
cat <
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<resource-agent name="rabbitmq-server">
|
|
Hubert Plociniczak |
7d96b2 |
<version>1.0</version>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
Resource agent for RabbitMQ-server
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">Resource agent for RabbitMQ-server</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<parameters>
|
|
Hubert Plociniczak |
7d96b2 |
<parameter name="multi" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
The path to the rabbitmq-multi script
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">Path to rabbitmq-multi</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<content type="string" default="${OCF_RESKEY_multi_default}" />
|
|
Hubert Plociniczak |
7d96b2 |
</parameter>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<parameter name="ctl" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
The path to the rabbitmqctl script
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">Path to rabbitmqctl</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<content type="string" default="${OCF_RESKEY_ctl_default}" />
|
|
Hubert Plociniczak |
7d96b2 |
</parameter>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<parameter name="nodename" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
The node name for rabbitmq-server
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">Node name</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<content type="string" default="${OCF_RESKEY_nodename_default}" />
|
|
Hubert Plociniczak |
7d96b2 |
</parameter>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<parameter name="ip" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
The IP address for rabbitmq-server to listen on
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">IP Address</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<content type="string" default="" />
|
|
Hubert Plociniczak |
7d96b2 |
</parameter>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<parameter name="port" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
The IP Port for rabbitmq-server to listen on
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">IP Port</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<content type="integer" default="" />
|
|
Hubert Plociniczak |
7d96b2 |
</parameter>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<parameter name="config_file" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
Location of the config file
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">Config file path</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<content type="string" default="" />
|
|
Hubert Plociniczak |
7d96b2 |
</parameter>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<parameter name="log_base" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
Location of the directory under which logs will be created
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">Log base path</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<content type="string" default="${OCF_RESKEY_log_base_default}" />
|
|
Hubert Plociniczak |
7d96b2 |
</parameter>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<parameter name="mnesia_base" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
Location of the directory under which mnesia will store data
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">Mnesia base path</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<content type="string" default="" />
|
|
Hubert Plociniczak |
7d96b2 |
</parameter>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<parameter name="server_start_args" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
Hubert Plociniczak |
7d96b2 |
Additional arguments provided to the server on startup
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<shortdesc lang="en">Server start arguments</shortdesc>
|
|
Hubert Plociniczak |
7d96b2 |
<content type="string" default="" />
|
|
Hubert Plociniczak |
7d96b2 |
</parameter>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
</parameters>
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
<actions>
|
|
Hubert Plociniczak |
7d96b2 |
<action name="start" timeout="600" />
|
|
Hubert Plociniczak |
7d96b2 |
<action name="stop" timeout="120" />
|
|
Hubert Plociniczak |
7d96b2 |
<action name="status" timeout="20" interval="10" />
|
|
Hubert Plociniczak |
7d96b2 |
<action name="monitor" timeout="20" interval="10" />
|
|
Hubert Plociniczak |
7d96b2 |
<action name="validate-all" timeout="30" />
|
|
Hubert Plociniczak |
7d96b2 |
<action name="meta-data" timeout="5" />
|
|
Hubert Plociniczak |
7d96b2 |
</actions>
|
|
Hubert Plociniczak |
7d96b2 |
</resource-agent>
|
|
Hubert Plociniczak |
7d96b2 |
END
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_usage() {
|
|
Hubert Plociniczak |
7d96b2 |
cat <
|
|
Hubert Plociniczak |
7d96b2 |
usage: $0 {start|stop|status|monitor|validate-all|meta-data}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
Expects to have a fully populated OCF RA-compliant environment set.
|
|
Hubert Plociniczak |
7d96b2 |
END
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
RABBITMQ_MULTI=$OCF_RESKEY_multi
|
|
Hubert Plociniczak |
7d96b2 |
RABBITMQ_CTL=$OCF_RESKEY_ctl
|
|
Hubert Plociniczak |
7d96b2 |
RABBITMQ_NODENAME=$OCF_RESKEY_nodename
|
|
Hubert Plociniczak |
7d96b2 |
RABBITMQ_NODE_IP_ADDRESS=$OCF_RESKEY_ip
|
|
Hubert Plociniczak |
7d96b2 |
RABBITMQ_NODE_PORT=$OCF_RESKEY_port
|
|
Hubert Plociniczak |
7d96b2 |
RABBITMQ_CONFIG_FILE=$OCF_RESKEY_config_file
|
|
Hubert Plociniczak |
7d96b2 |
RABBITMQ_LOG_BASE=$OCF_RESKEY_log_base
|
|
Hubert Plociniczak |
7d96b2 |
RABBITMQ_MNESIA_BASE=$OCF_RESKEY_mnesia_base
|
|
Hubert Plociniczak |
7d96b2 |
RABBITMQ_SERVER_START_ARGS=$OCF_RESKEY_server_start_args
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_NODENAME ] && NODENAME_ARG="-n $RABBITMQ_NODENAME"
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_NODENAME ] && export RABBITMQ_NODENAME
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
export_vars() {
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_NODE_IP_ADDRESS ] && export RABBITMQ_NODE_IP_ADDRESS
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_NODE_PORT ] && export RABBITMQ_NODE_PORT
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_CONFIG_FILE ] && export RABBITMQ_CONFIG_FILE
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_LOG_BASE ] && export RABBITMQ_LOG_BASE
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_MNESIA_BASE ] && export RABBITMQ_MNESIA_BASE
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_SERVER_START_ARGS ] && export RABBITMQ_SERVER_START_ARGS
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_validate_partial() {
|
|
Hubert Plociniczak |
7d96b2 |
if [ ! -x $RABBITMQ_MULTI ]; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log err "rabbitmq-server multi $RABBITMQ_MULTI does not exist or is not executable";
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_ERR_INSTALLED;
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
if [ ! -x $RABBITMQ_CTL ]; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log err "rabbitmq-server ctl $RABBITMQ_CTL does not exist or is not executable";
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_ERR_INSTALLED;
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_validate_full() {
|
|
Hubert Plociniczak |
7d96b2 |
if [ ! -z $RABBITMQ_CONFIG_FILE ] && [ ! -e $RABBITMQ_CONFIG_FILE ]; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log err "rabbitmq-server config_file $RABBITMQ_CONFIG_FILE does not exist or is not a file";
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_ERR_INSTALLED;
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
if [ ! -z $RABBITMQ_LOG_BASE ] && [ ! -d $RABBITMQ_LOG_BASE ]; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log err "rabbitmq-server log_base $RABBITMQ_LOG_BASE does not exist or is not a directory";
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_ERR_INSTALLED;
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
if [ ! -z $RABBITMQ_MNESIA_BASE ] && [ ! -d $RABBITMQ_MNESIA_BASE ]; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log err "rabbitmq-server mnesia_base $RABBITMQ_MNESIA_BASE does not exist or is not a directory";
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_ERR_INSTALLED;
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_validate_partial
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
return $OCF_SUCCESS
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_status() {
|
|
Hubert Plociniczak |
7d96b2 |
local rc
|
|
Hubert Plociniczak |
7d96b2 |
$RABBITMQ_CTL $NODENAME_ARG status > /dev/null 2> /dev/null
|
|
Hubert Plociniczak |
7d96b2 |
rc=$?
|
|
Hubert Plociniczak |
7d96b2 |
case "$rc" in
|
|
Hubert Plociniczak |
7d96b2 |
0)
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log debug "RabbitMQ server is running normally"
|
|
Hubert Plociniczak |
7d96b2 |
return $OCF_SUCCESS
|
|
Hubert Plociniczak |
7d96b2 |
;;
|
|
Hubert Plociniczak |
7d96b2 |
2)
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log debug "RabbitMQ server is not running"
|
|
Hubert Plociniczak |
7d96b2 |
return $OCF_NOT_RUNNING
|
|
Hubert Plociniczak |
7d96b2 |
;;
|
|
Hubert Plociniczak |
7d96b2 |
*)
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log err "Unexpected return from rabbitmqctl $NODENAME_ARG status: $rc"
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_ERR_GENERIC
|
|
Hubert Plociniczak |
7d96b2 |
esac
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_start() {
|
|
Hubert Plociniczak |
7d96b2 |
local rc
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
if rabbit_status; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log info "Resource already running."
|
|
Hubert Plociniczak |
7d96b2 |
return $OCF_SUCCESS
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
export_vars
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
$RABBITMQ_MULTI start_all 1 > ${RABBITMQ_LOG_BASE}/startup_log 2> ${RABBITMQ_LOG_BASE}/startup_err &
|
|
Hubert Plociniczak |
7d96b2 |
rc=$?
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
if [ "$rc" != 0 ]; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log err "rabbitmq-server start command failed: $RABBITMQ_MULTI start_all 1, $rc"
|
|
Hubert Plociniczak |
7d96b2 |
return $rc
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
# Spin waiting for the server to come up.
|
|
Hubert Plociniczak |
7d96b2 |
# Let the CRM/LRM time us out if required
|
|
Hubert Plociniczak |
7d96b2 |
start_wait=1
|
|
Hubert Plociniczak |
7d96b2 |
while [ $start_wait = 1 ]; do
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_status
|
|
Hubert Plociniczak |
7d96b2 |
rc=$?
|
|
Hubert Plociniczak |
7d96b2 |
if [ "$rc" = $OCF_SUCCESS ]; then
|
|
Hubert Plociniczak |
7d96b2 |
start_wait=0
|
|
Hubert Plociniczak |
7d96b2 |
elif [ "$rc" != $OCF_NOT_RUNNING ]; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log info "rabbitmq-server start failed: $rc"
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_ERR_GENERIC
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
sleep 1
|
|
Hubert Plociniczak |
7d96b2 |
done
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
return $OCF_SUCCESS
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_stop() {
|
|
Hubert Plociniczak |
7d96b2 |
local rc
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
if ! rabbit_status; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log info "Resource not running."
|
|
Hubert Plociniczak |
7d96b2 |
return $OCF_SUCCESS
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
$RABBITMQ_MULTI stop_all &
|
|
Hubert Plociniczak |
7d96b2 |
rc=$?
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
if [ "$rc" != 0 ]; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log err "rabbitmq-server stop command failed: $RABBITMQ_MULTI stop_all, $rc"
|
|
Hubert Plociniczak |
7d96b2 |
return $rc
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
# Spin waiting for the server to shut down.
|
|
Hubert Plociniczak |
7d96b2 |
# Let the CRM/LRM time us out if required
|
|
Hubert Plociniczak |
7d96b2 |
stop_wait=1
|
|
Hubert Plociniczak |
7d96b2 |
while [ $stop_wait = 1 ]; do
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_status
|
|
Hubert Plociniczak |
7d96b2 |
rc=$?
|
|
Hubert Plociniczak |
7d96b2 |
if [ "$rc" = $OCF_NOT_RUNNING ]; then
|
|
Hubert Plociniczak |
7d96b2 |
stop_wait=0
|
|
Hubert Plociniczak |
7d96b2 |
break
|
|
Hubert Plociniczak |
7d96b2 |
elif [ "$rc" != $OCF_SUCCESS ]; then
|
|
Hubert Plociniczak |
7d96b2 |
ocf_log info "rabbitmq-server stop failed: $rc"
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_ERR_GENERIC
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
sleep 1
|
|
Hubert Plociniczak |
7d96b2 |
done
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
return $OCF_SUCCESS
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_monitor() {
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_status
|
|
Hubert Plociniczak |
7d96b2 |
return $?
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
case $__OCF_ACTION in
|
|
Hubert Plociniczak |
7d96b2 |
meta-data)
|
|
Hubert Plociniczak |
7d96b2 |
meta_data
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_SUCCESS
|
|
Hubert Plociniczak |
7d96b2 |
;;
|
|
Hubert Plociniczak |
7d96b2 |
usage|help)
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_usage
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_SUCCESS
|
|
Hubert Plociniczak |
7d96b2 |
;;
|
|
Hubert Plociniczak |
7d96b2 |
esac
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
if ocf_is_probe; then
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_validate_partial
|
|
Hubert Plociniczak |
7d96b2 |
else
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_validate_full
|
|
Hubert Plociniczak |
7d96b2 |
fi
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
case $__OCF_ACTION in
|
|
Hubert Plociniczak |
7d96b2 |
start)
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_start
|
|
Hubert Plociniczak |
7d96b2 |
;;
|
|
Hubert Plociniczak |
7d96b2 |
stop)
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_stop
|
|
Hubert Plociniczak |
7d96b2 |
;;
|
|
Hubert Plociniczak |
7d96b2 |
status|monitor)
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_monitor
|
|
Hubert Plociniczak |
7d96b2 |
;;
|
|
Hubert Plociniczak |
7d96b2 |
validate-all)
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_SUCCESS
|
|
Hubert Plociniczak |
7d96b2 |
;;
|
|
Hubert Plociniczak |
7d96b2 |
*)
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_usage
|
|
Hubert Plociniczak |
7d96b2 |
exit $OCF_ERR_UNIMPLEMENTED
|
|
Hubert Plociniczak |
7d96b2 |
;;
|
|
Hubert Plociniczak |
7d96b2 |
esac
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
exit $?
|