|
Hubert Plociniczak |
7d96b2 |
#!/bin/sh
|
|
|
f44ad9 |
## The contents of this file are subject to the Mozilla Public License
|
|
|
f44ad9 |
## Version 1.1 (the "License"); you may not use this file except in
|
|
|
f44ad9 |
## compliance with the License. You may obtain a copy of the License
|
|
|
f44ad9 |
## at http://www.mozilla.org/MPL/
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
|
f44ad9 |
## Software distributed under the License is distributed on an "AS IS"
|
|
|
f44ad9 |
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
|
f44ad9 |
## the License for the specific language governing rights and
|
|
|
f44ad9 |
## limitations under the License.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
|
f44ad9 |
## The Original Code is RabbitMQ.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
|
f44ad9 |
## The Initial Developer of the Original Code is VMware, Inc.
|
|
|
d817ac |
## Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
|
f44ad9 |
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
|
f44ad9 |
## OCF Resource Agent compliant rabbitmq-server resource script.
|
|
Hubert Plociniczak |
7d96b2 |
##
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
## OCF instance parameters
|
|
|
f44ad9 |
## OCF_RESKEY_server
|
|
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
|
|
|
f44ad9 |
## OCF_RESKEY_pid_file
|
|
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 |
|
|
|
f44ad9 |
OCF_RESKEY_server_default="/usr/sbin/rabbitmq-server"
|
|
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"
|
|
|
f44ad9 |
OCF_RESKEY_pid_file_default="/var/run/rabbitmq/pid"
|
|
|
f44ad9 |
: ${OCF_RESKEY_server=${OCF_RESKEY_server_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}}
|
|
|
f44ad9 |
: ${OCF_RESKEY_pid_file=${OCF_RESKEY_pid_file_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>
|
|
|
f44ad9 |
<parameter name="server" unique="0" required="0">
|
|
Hubert Plociniczak |
7d96b2 |
<longdesc lang="en">
|
|
|
f44ad9 |
The path to the rabbitmq-server script
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
|
f44ad9 |
<shortdesc lang="en">Path to rabbitmq-server</shortdesc>
|
|
|
f44ad9 |
<content type="string" default="${OCF_RESKEY_server_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">
|
|
|
f44ad9 |
Location of the config file (without the .config suffix)
|
|
Hubert Plociniczak |
7d96b2 |
</longdesc>
|
|
|
f44ad9 |
<shortdesc lang="en">Config file path (without the .config suffix)</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 |
|
|
|
f44ad9 |
<parameter name="pid_file" unique="0" required="0">
|
|
|
f44ad9 |
<longdesc lang="en">
|
|
|
f44ad9 |
Location of the file in which the pid will be stored
|
|
|
f44ad9 |
</longdesc>
|
|
|
f44ad9 |
<shortdesc lang="en">Pid file path</shortdesc>
|
|
|
f44ad9 |
<content type="string" default="${OCF_RESKEY_pid_file_default}" />
|
|
|
f44ad9 |
</parameter>
|
|
|
f44ad9 |
|
|
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 |
|
|
|
f44ad9 |
RABBITMQ_SERVER=$OCF_RESKEY_server
|
|
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
|
|
|
f44ad9 |
RABBITMQ_PID_FILE=$OCF_RESKEY_pid_file
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_NODENAME ] && NODENAME_ARG="-n $RABBITMQ_NODENAME"
|
|
Hubert Plociniczak |
7d96b2 |
[ ! -z $RABBITMQ_NODENAME ] && export RABBITMQ_NODENAME
|
|
Hubert Plociniczak |
7d96b2 |
|
|
|
f44ad9 |
ensure_pid_dir () {
|
|
|
f44ad9 |
PID_DIR=`dirname ${RABBITMQ_PID_FILE}`
|
|
|
f44ad9 |
if [ ! -d ${PID_DIR} ] ; then
|
|
|
f44ad9 |
mkdir -p ${PID_DIR}
|
|
|
f44ad9 |
chown -R rabbitmq:rabbitmq ${PID_DIR}
|
|
|
f44ad9 |
chmod 755 ${PID_DIR}
|
|
|
f44ad9 |
fi
|
|
|
f44ad9 |
return $OCF_SUCCESS
|
|
|
f44ad9 |
}
|
|
|
f44ad9 |
|
|
|
f44ad9 |
remove_pid () {
|
|
|
f44ad9 |
rm -f ${RABBITMQ_PID_FILE}
|
|
|
f44ad9 |
rmdir `dirname ${RABBITMQ_PID_FILE}` || :
|
|
|
f44ad9 |
}
|
|
|
f44ad9 |
|
|
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
|
|
|
f44ad9 |
[ ! -z $RABBITMQ_PID_FILE ] && ensure_pid_dir && export RABBITMQ_PID_FILE
|
|
Hubert Plociniczak |
7d96b2 |
}
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
rabbit_validate_partial() {
|
|
|
f44ad9 |
if [ ! -x $RABBITMQ_SERVER ]; then
|
|
|
f44ad9 |
ocf_log err "rabbitmq-server server $RABBITMQ_SERVER 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() {
|
|
|
f44ad9 |
if [ ! -z $RABBITMQ_CONFIG_FILE ] && [ ! -e "${RABBITMQ_CONFIG_FILE}.config" ]; then
|
|
|
f44ad9 |
ocf_log err "rabbitmq-server config_file ${RABBITMQ_CONFIG_FILE}.config 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() {
|
|
|
f44ad9 |
rabbitmqctl_action "status"
|
|
|
f44ad9 |
}
|
|
|
f44ad9 |
|
|
|
f44ad9 |
rabbit_wait() {
|
|
|
f44ad9 |
rabbitmqctl_action "wait" $1
|
|
|
f44ad9 |
}
|
|
|
f44ad9 |
|
|
|
f44ad9 |
rabbitmqctl_action() {
|
|
Hubert Plociniczak |
7d96b2 |
local rc
|
|
|
f44ad9 |
local action
|
|
|
f44ad9 |
action=$@
|
|
|
f44ad9 |
$RABBITMQ_CTL $NODENAME_ARG $action > /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 |
*)
|
|
|
f44ad9 |
ocf_log err "Unexpected return from rabbitmqctl $NODENAME_ARG $action: $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 |
|
|
|
f44ad9 |
setsid sh -c "$RABBITMQ_SERVER > ${RABBITMQ_LOG_BASE}/startup_log 2> ${RABBITMQ_LOG_BASE}/startup_err" &
|
|
Hubert Plociniczak |
7d96b2 |
|
|
|
f44ad9 |
# Wait for the server to come up.
|
|
Hubert Plociniczak |
7d96b2 |
# Let the CRM/LRM time us out if required
|
|
|
f44ad9 |
rabbit_wait $RABBITMQ_PID_FILE
|
|
|
f44ad9 |
rc=$?
|
|
|
f44ad9 |
if [ "$rc" != $OCF_SUCCESS ]; then
|
|
|
f44ad9 |
remove_pid
|
|
|
f44ad9 |
ocf_log info "rabbitmq-server start failed: $rc"
|
|
|
f44ad9 |
exit $OCF_ERR_GENERIC
|
|
|
f44ad9 |
fi
|
|
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 |
|
|
|
f44ad9 |
$RABBITMQ_CTL stop
|
|
Hubert Plociniczak |
7d96b2 |
rc=$?
|
|
Hubert Plociniczak |
7d96b2 |
|
|
Hubert Plociniczak |
7d96b2 |
if [ "$rc" != 0 ]; then
|
|
|
f44ad9 |
ocf_log err "rabbitmq-server stop command failed: $RABBITMQ_CTL stop, $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
|
|
|
f44ad9 |
remove_pid
|
|
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 $?
|