@@ -323,22 +323,23 @@ proc_kill()
323
323
{
324
324
local pid=" ${1} "
325
325
local service_name=" ${2} "
326
- local signal=${3:- SIGTERM}
327
- local count=${4:- 5}
328
- local process_sleep=${5:- 2}
326
+ local signal=" ${3:- SIGTERM} "
327
+ local count=" ${4:- 5} "
328
+ local process_sleep=" ${5:- 2} "
329
329
local LH=" ${LL} proc_kill():"
330
- local pgrp=$( ps -o pgid= ${pid} | tr -d ' [[:space:]]' )
330
+ local pgrp=" $( ps -o pgid= ${pid} | tr -d ' [[:space:]]' ) "
331
331
332
332
if [ " ${pid} " -a " ${pgrp} " = " 1" ] ; then
333
333
ocf_log err " ${LH} shall not kill by the bad pid 1 (init)!"
334
334
return 2
335
335
fi
336
336
337
337
if [ -z " ${pid} " ]; then
338
- ocf_log info " ${LH} no pid provided, will try the ${service_name} "
339
- ocf_run pkill -f -${signal} " ${service_name} "
340
- rc=$?
341
- if [ $rc -eq 0 ] ; then
338
+ local matched
339
+ matched=" $( pgrep -fla ${service_name} ) "
340
+ ocf_log info " ${LH} no pid provided, will try the ${service_name} , matched list: ${matched} "
341
+ ocf_run pkill -f -" ${signal} " " ${service_name} "
342
+ if [ $? -eq 0 ] ; then
342
343
ocf_log warn " ${LH} sent kill -${signal} to processes matched the ${service_name} "
343
344
return 0
344
345
else
@@ -348,23 +349,18 @@ proc_kill()
348
349
fi
349
350
350
351
while [ $count -gt 0 ]; do
351
- if [ -d /proc/${pid} ]; then
352
- ocf_log debug " ${LH} Stopping ${service_name} with ${signal} ..."
353
- ocf_run pkill -${signal} -g " ${pgrp} "
354
- if [ ! -d /proc/${pid} ] ; then
355
- ocf_log debug " ${LH} Stopped ${service_name} with ${signal} "
356
- return 0
357
- fi
352
+ if [ ! -d " /proc/${pid} " ]; then
353
+ break
358
354
else
359
- ocf_log debug " ${LH} Stopped ${service_name} with ${signal} "
360
- return 0
355
+ ocf_log debug " ${LH} Stopping ${service_name} with ${signal} ... "
356
+ ocf_run pkill - " ${signal} " -g " ${pgrp} "
361
357
fi
362
358
sleep $process_sleep
363
359
count=$(( count- 1 ))
364
360
done
365
361
366
362
# Check if the process ended after the last sleep
367
- if [ ! -d /proc/${pid} ] ; then
363
+ if [ ! -d " /proc/${pid} " ] ; then
368
364
ocf_log debug " ${LH} Stopped ${service_name} with ${signal} "
369
365
return 0
370
366
fi
@@ -396,7 +392,7 @@ proc_stop()
396
392
{
397
393
local pid_param=" ${1} "
398
394
local service_name=" ${2} "
399
- local timeout=${3:- 15}
395
+ local timeout=" ${3:- 15} "
400
396
local LH=" ${LL} proc_stop():"
401
397
local pid
402
398
local pidfile
@@ -761,11 +757,9 @@ update_cookie() {
761
757
762
758
# Stop rmq beam process by pid or rabbit node name match. Returns SUCCESS/ERROR
763
759
kill_rmq_and_remove_pid () {
764
- local rc
765
760
local LH=" ${LL} kill_rmq_and_remove_pid():"
766
761
proc_stop " ${OCF_RESKEY_pid_file} " " beam.*${RABBITMQ_NODENAME} " " ${OCF_RESKEY_stop_time} "
767
- rc=$?
768
- if [ $rc -eq 0 ] ; then
762
+ if [ $? -eq 0 ] ; then
769
763
return $OCF_SUCCESS
770
764
else
771
765
return $OCF_ERR_GENERIC
@@ -1280,8 +1274,7 @@ check_timeouts() {
1280
1274
1281
1275
local count
1282
1276
count=` crm_attribute -N $THIS_PCMK_NODE -l reboot --name $crm_attr_name --query 2> /dev/null`
1283
- op_rc=$?
1284
- if [ $op_rc -ne 0 ]; then
1277
+ if [ $? -ne 0 ]; then
1285
1278
# the crm_attribute exited with error. In that case most probably it printed garbage
1286
1279
# instead of the number we need. So defensively assume that it is zero.
1287
1280
@@ -1633,8 +1626,7 @@ action_stop() {
1633
1626
1634
1627
# Ensure the actual status to be returned
1635
1628
get_status
1636
- rc=$?
1637
- if [ $rc -eq $OCF_NOT_RUNNING ] ; then
1629
+ if [ $? -eq $OCF_NOT_RUNNING ] ; then
1638
1630
ocf_log info " ${LH} RMQ-runtime (beam) not running."
1639
1631
ocf_log info " ${LH} action end."
1640
1632
return $OCF_SUCCESS
0 commit comments