From 3fc846d7891509499da066c1d1f63899a8dcf450 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 4 Mar 2019 15:53:18 -0800 Subject: [PATCH] Try to use the RPC exit API to cleanly exit nodes --- ci/localnet-sanity.sh | 20 ++++++++++++++++++++ multinode-demo/fullnode.sh | 3 +++ 2 files changed, 23 insertions(+) diff --git a/ci/localnet-sanity.sh b/ci/localnet-sanity.sh index 2056be2c3..42cf144a7 100755 --- a/ci/localnet-sanity.sh +++ b/ci/localnet-sanity.sh @@ -79,9 +79,11 @@ nodes=( "multinode-demo/drone.sh" "multinode-demo/bootstrap-leader.sh \ $maybeNoLeaderRotation \ + --enable-rpc-exit \ --init-complete-file init-complete-node1.log" "multinode-demo/fullnode.sh \ $maybeNoLeaderRotation \ + --enable-rpc-exit \ --init-complete-file init-complete-node2.log \ --rpc-port 18899" ) @@ -177,6 +179,24 @@ killNode() { } killNodes() { + [[ ${#pids[@]} -gt 0 ]] || return + + # Try to use the RPC exit API to cleanly exit the first two nodes + # (dynamic nodes, -x, are just killed since their RPC port is not known) + echo "--- RPC exit" + for port in 8899 18899; do + ( + set -x + curl --retry 5 --retry-delay 2 --retry-connrefused \ + -X POST -H 'Content-Type: application/json' \ + -d '{"jsonrpc":"2.0","id":1, "method":"fullnodeExit"}' \ + http://localhost:$port + ) + done + + # Give the nodes a splash of time to cleanly exit before killing them + sleep 2 + echo "--- Killing nodes" for pid in "${pids[@]}"; do killNode "$pid" diff --git a/multinode-demo/fullnode.sh b/multinode-demo/fullnode.sh index 294a10ddb..e7f0d204c 100755 --- a/multinode-demo/fullnode.sh +++ b/multinode-demo/fullnode.sh @@ -53,6 +53,9 @@ while [[ ${1:0:1} = - ]]; do elif [[ $1 = --blockstream ]]; then extra_fullnode_args+=("$1" "$2") shift 2 + elif [[ $1 = --enable-rpc-exit ]]; then + extra_fullnode_args+=("$1") + shift elif [[ $1 = --init-complete-file ]]; then extra_fullnode_args+=("$1" "$2") shift 2