From d349efba575a4b0453b6118b65800830d2efb4cd Mon Sep 17 00:00:00 2001 From: Alvin Moore Date: Tue, 1 Sep 2020 10:08:52 -0400 Subject: [PATCH] Added support for killing the cluster gracefully --- contrib/Joshua/scripts/bindingTestScript.sh | 5 +++++ contrib/Joshua/scripts/localClusterStart.sh | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/contrib/Joshua/scripts/bindingTestScript.sh b/contrib/Joshua/scripts/bindingTestScript.sh index 135a4ada86..971039f3c8 100755 --- a/contrib/Joshua/scripts/bindingTestScript.sh +++ b/contrib/Joshua/scripts/bindingTestScript.sh @@ -80,4 +80,9 @@ if [ "${status}" -ne 0 ] && [ "${SAVEONERROR}" -gt 0 ]; then env > "${LOGDIR}/env.log" fi +# Stop the cluster +if stopCluster; then + unset FDBSERVERID +fi + exit "${status}" diff --git a/contrib/Joshua/scripts/localClusterStart.sh b/contrib/Joshua/scripts/localClusterStart.sh index 90852c9f7d..cbdbb9216e 100644 --- a/contrib/Joshua/scripts/localClusterStart.sh +++ b/contrib/Joshua/scripts/localClusterStart.sh @@ -22,6 +22,7 @@ let index3="${RANDOM} % 256" let index4="(${RANDOM} % 255) + 1" # Define a random ip address on localhost IPADDRESS="127.${index2}.${index3}.${index4}" +CLUSTERSTRING="${IPADDRESS}:${FDBSERVERPORT}" function log @@ -178,7 +179,7 @@ function createClusterFile { function stopCluster { # Add an audit entree, if enabled if [ "${AUDITCLUSTER}" -gt 0 ]; then - printf '%-15s (%6s) Stopping Fdbserver (%6s)\n' "$(date +'%Y-%m-%d %H:%M:%S')" "${$}" "${FDBSERVERID}" >> "${AUDITLOG}" + printf '%-15s (%6s) Stopping cluster %-20s (%6s): %s\n' "$(date +'%Y-%m-%d %H:%M:%S')" "${$}" "${CLUSTERSTRING}" "${FDBSERVERID}" >> "${AUDITLOG}" fi if [ -z "${FDBSERVERID}" ]; then log 'FDB Server process is not defined' @@ -186,11 +187,15 @@ function stopCluster { elif ! kill -0 "${FDBSERVERID}"; then log "Failed to locate FDB Server process (${FDBSERVERID})" let status="${status} + 1" + elif "${BINDIR}/fdbcli" -C "${FDBCONF}" --exec 'kill all' --timeout 120 &>> "${LOGDIR}/fdbcli-kill.log" + then + log "Killed cluster (${FDBSERVERID}) via cli" + elif ! kill -9 "${FDBSERVERID}"; then - log "Failed to kill FDB Server process (${FDBSERVERID})" + log "Failed to forcibly kill FDB Server process (${FDBSERVERID})" let status="${status} + 1" else - log "Killed FDB Server process (${FDBSERVERID})" + log "Forcibly killed FDB Server process (${FDBSERVERID})" fi return "${status}" } @@ -199,7 +204,7 @@ function stopCluster { function startFdbServer { # Add an audit entree, if enabled if [ "${AUDITCLUSTER}" -gt 0 ]; then - printf '%-15s (%6s) Starting Fdbserver\n' "$(date +'%Y-%m-%d %H:%M:%S')" "${$}" >> "${AUDITLOG}" + printf '%-15s (%6s) Starting cluster %-20s\n' "$(date +'%Y-%m-%d %H:%M:%S')" "${$}" "${CLUSTERSTRING}" >> "${AUDITLOG}" fi if [ "${status}" -ne 0 ]; then