diff options
| author | Bogdan Dobrelya <bdobrelia@mirantis.com> | 2016-01-11 10:05:52 +0100 |
|---|---|---|
| committer | Bogdan Dobrelya <bdobrelia@mirantis.com> | 2016-01-11 10:59:20 +0100 |
| commit | b00c0576ddd2cc19834c744bf297f5c9ca27bb5e (patch) | |
| tree | 9cfc87d1d869b57ef0be316cc3a64eefc242fd36 /scripts/rabbitmq-server-ha.ocf | |
| parent | 0f77ae3f47fabeebdb75644e61b183daddfc3917 (diff) | |
| download | rabbitmq-server-git-b00c0576ddd2cc19834c744bf297f5c9ca27bb5e.tar.gz | |
Syntax and local vars usage fixes to OCF HA
Related Fuel bug:
https://launchpad.net/bugs/1529897
Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
Diffstat (limited to 'scripts/rabbitmq-server-ha.ocf')
| -rwxr-xr-x | scripts/rabbitmq-server-ha.ocf | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/scripts/rabbitmq-server-ha.ocf b/scripts/rabbitmq-server-ha.ocf index 6cec4f1864..05b4236ad5 100755 --- a/scripts/rabbitmq-server-ha.ocf +++ b/scripts/rabbitmq-server-ha.ocf @@ -323,11 +323,11 @@ proc_kill() { local pid="${1}" local service_name="${2}" - local signal=${3:-SIGTERM} - local count=${4:-5} - local process_sleep=${5:-2} + local signal="${3:-SIGTERM}" + local count="${4:-5}" + local process_sleep="${5:-2}" local LH="${LL} proc_kill():" - local pgrp=$(ps -o pgid= ${pid} | tr -d '[[:space:]]') + local pgrp="$(ps -o pgid= ${pid} | tr -d '[[:space:]]')" if [ "${pid}" -a "${pgrp}" = "1" ] ; then ocf_log err "${LH} shall not kill by the bad pid 1 (init)!" @@ -335,10 +335,11 @@ proc_kill() fi if [ -z "${pid}" ]; then - ocf_log info "${LH} no pid provided, will try the ${service_name}" - ocf_run pkill -f -${signal} "${service_name}" - rc=$? - if [ $rc -eq 0 ] ; then + local matched + matched="$(pgrep -fla ${service_name})" + ocf_log info "${LH} no pid provided, will try the ${service_name}, matched list: ${matched}" + ocf_run pkill -f -"${signal}" "${service_name}" + if [ $? -eq 0 ] ; then ocf_log warn "${LH} sent kill -${signal} to processes matched the ${service_name}" return 0 else @@ -348,23 +349,18 @@ proc_kill() fi while [ $count -gt 0 ]; do - if [ -d /proc/${pid} ]; then - ocf_log debug "${LH} Stopping ${service_name} with ${signal}..." - ocf_run pkill -${signal} -g "${pgrp}" - if [ ! -d /proc/${pid} ] ; then - ocf_log debug "${LH} Stopped ${service_name} with ${signal}" - return 0 - fi + if [ ! -d "/proc/${pid}" ]; then + break else - ocf_log debug "${LH} Stopped ${service_name} with ${signal}" - return 0 + ocf_log debug "${LH} Stopping ${service_name} with ${signal}..." + ocf_run pkill -"${signal}" -g "${pgrp}" fi sleep $process_sleep count=$(( count-1 )) done # Check if the process ended after the last sleep - if [ ! -d /proc/${pid} ] ; then + if [ ! -d "/proc/${pid}" ] ; then ocf_log debug "${LH} Stopped ${service_name} with ${signal}" return 0 fi @@ -396,7 +392,7 @@ proc_stop() { local pid_param="${1}" local service_name="${2}" - local timeout=${3:-15} + local timeout="${3:-15}" local LH="${LL} proc_stop():" local pid local pidfile @@ -761,11 +757,9 @@ update_cookie() { # Stop rmq beam process by pid or rabbit node name match. Returns SUCCESS/ERROR kill_rmq_and_remove_pid() { - local rc local LH="${LL} kill_rmq_and_remove_pid():" proc_stop "${OCF_RESKEY_pid_file}" "beam.*${RABBITMQ_NODENAME}" "${OCF_RESKEY_stop_time}" - rc=$? - if [ $rc -eq 0 ] ; then + if [ $? -eq 0 ] ; then return $OCF_SUCCESS else return $OCF_ERR_GENERIC @@ -1280,8 +1274,7 @@ check_timeouts() { local count count=`crm_attribute -N $THIS_PCMK_NODE -l reboot --name $crm_attr_name --query 2>/dev/null` - op_rc=$? - if [ $op_rc -ne 0 ]; then + if [ $? -ne 0 ]; then # the crm_attribute exited with error. In that case most probably it printed garbage # instead of the number we need. So defensively assume that it is zero. @@ -1633,8 +1626,7 @@ action_stop() { # Ensure the actual status to be returned get_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ] ; then + if [ $? -eq $OCF_NOT_RUNNING ] ; then ocf_log info "${LH} RMQ-runtime (beam) not running." ocf_log info "${LH} action end." return $OCF_SUCCESS |
