Skip to content

Commit

Permalink
ctdb-scripts: Improve CTDB wrapper shutdown code
Browse files Browse the repository at this point in the history
This will make it easier to run things after CTDB is stopped.

Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Michael Adam <[email protected]>
  • Loading branch information
martin-schwenke authored and obnoxxx committed Nov 9, 2015
1 parent 3a7c73f commit f05c6d3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions ctdb/config/ctdbd_wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,29 @@ stop()
# Wait for remaining CTDB processes to exit...
_timeout=${CTDB_SHUTDOWN_TIMEOUT:-30}
_count=0
_terminated=false
while [ $_count -lt $_timeout ] ; do
pkill -0 -s "$_session" 2>/dev/null || return 0
if ! pkill -0 -s "$_session" 2>/dev/null ; then
_terminated=true
break
fi

_count=$(($_count + 1))
sleep 1
done

echo "Timed out waiting for CTDB to shutdown. Killing CTDB processes."
kill_ctdbd "$_session"
drop_all_public_ips >/dev/null 2>&1
if ! $_terminated ; then
echo "Timed out waiting for CTDB to shutdown. Killing CTDB processes."
kill_ctdbd "$_session"
drop_all_public_ips >/dev/null 2>&1

sleep 1
sleep 1

if pkill -0 -s "$_session" ; then
# If SIGKILL didn't work then things are bad...
echo "Failed to kill all CTDB processes. Giving up."
return 1
if pkill -0 -s "$_session" ; then
# If SIGKILL didn't work then things are bad...
echo "Failed to kill all CTDB processes. Giving up."
return 1
fi
fi

return 0
Expand Down

0 comments on commit f05c6d3

Please sign in to comment.