From fd8a3935febadf012b54ac9f545611af16363f99 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Mon, 19 Aug 2019 17:33:36 -0700 Subject: [PATCH 1/2] Only kill processes with matching binary names --- test/kill_node.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/kill_node.sh b/test/kill_node.sh index c173ade25..b05e93df0 100755 --- a/test/kill_node.sh +++ b/test/kill_node.sh @@ -1,9 +1,3 @@ #!/bin/bash - -for pid in `/bin/ps -fu $USER| grep "harmony\|txgen\|soldier\|commander\|profiler\|beacon\|bootnode" | grep -v "grep" | grep -v "vi" | awk '{print $2}'`; -do - echo 'Killed process: '$pid - kill -9 $pid -done - +pkill -9 '^(harmony|txgen|soldier|commander|profiler|beacon|bootnode)$' | sed 's/^/Killed process: /' rm -rf db-127.0.0.1-* From edef0987c5842bbc6b6bd2290839d0c74dc20b31 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Mon, 19 Aug 2019 17:41:01 -0700 Subject: [PATCH 2/2] Use kill_node.sh for killing nodes --- test/deploy.sh | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/test/deploy.sh b/test/deploy.sh index 3957b734c..ede961146 100755 --- a/test/deploy.sh +++ b/test/deploy.sh @@ -1,6 +1,12 @@ #!/bin/bash -ROOT=$(dirname $0)/.. +unset -v progdir +case "${0}" in +*/*) progdir="${0%/*}" ;; +*) progdir=. ;; +esac + +ROOT="${progdir}/.." USER=$(whoami) . "${ROOT}/scripts/setup_bls_build_flags.sh" @@ -30,24 +36,7 @@ function check_result() { } function cleanup() { - for pid in `/bin/ps -fu $USER| grep "harmony\|txgen\|soldier\|commander\|profiler\|bootnode" | grep -v "grep" | grep -v "vi" | awk '{print $2}'`; - do - echo 'Killed process: '$pid - $DRYRUN kill -9 $pid 2> /dev/null - done - rm -rf ./db/harmony_* - rm -rf ./db-127.0.0.1-* -} - -function killnode() { - local port=$1 - - if [ -n "port" ]; then - pid=$(/bin/ps -fu $USER | grep "harmony" | grep "$port" | awk '{print $2}') - echo "killing node with port: $port" - $DRYRUN kill -9 $pid 2> /dev/null - echo "node with port: $port is killed" - fi + "${progdir}/kill_node.sh" } trap cleanup SIGINT SIGTERM