From 41d0db078e76eba1eeb65e4e67bf9213f919f269 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 10 Jul 2019 21:03:48 -0700 Subject: [PATCH] Wait for bootstrap leader to initialize before starting other validators (#5027) --- ci/localnet-sanity.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/ci/localnet-sanity.sh b/ci/localnet-sanity.sh index f7d621bc96..9eaeaea5c1 100755 --- a/ci/localnet-sanity.sh +++ b/ci/localnet-sanity.sh @@ -125,21 +125,26 @@ startNode() { echo "log: $log" } +waitForNodeToInit() { + declare initCompleteFile=$1 + while [[ ! -r $initCompleteFile ]]; do + if [[ $SECONDS -ge 240 ]]; then + echo "^^^ +++" + echo "Error: $initCompleteFile not found in $SECONDS seconds" + exit 1 + fi + echo "Waiting for $initCompleteFile ($SECONDS)..." + sleep 2 + done + echo "Found $initCompleteFile" +} + initCompleteFiles=() waitForAllNodesToInit() { echo "--- ${#initCompleteFiles[@]} nodes booting" SECONDS= for initCompleteFile in "${initCompleteFiles[@]}"; do - while [[ ! -r $initCompleteFile ]]; do - if [[ $SECONDS -ge 240 ]]; then - echo "^^^ +++" - echo "Error: $initCompleteFile not found in $SECONDS seconds" - exit 1 - fi - echo "Waiting for $initCompleteFile ($SECONDS)..." - sleep 2 - done - echo "Found $initCompleteFile" + waitForNodeToInit "$initCompleteFile" done echo "All nodes finished booting in $SECONDS seconds" } @@ -162,6 +167,13 @@ startNodes() { if $addLogs; then logs+=("$(getNodeLogFile "$i" "$cmd")") fi + + # 1 == bootstrap leader, wait until it boots before starting + # other validators + if [[ "$i" -eq 1 ]]; then + SECONDS= + waitForNodeToInit "$initCompleteFile" + fi done waitForAllNodesToInit