Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wait_until_node_sync.sh accept custom for custom ports #1322

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions deploy_blockchain_genesis_onprem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ if [[ ! $2 =~ $number_re ]] ; then
printf "Invalid <# of Shards> argument: $2\n"
exit
fi
if [[ $3 -lt 0 ]] || [[ $3 -gt 4 ]]; then
printf "Invalid <Parent Node Index Begin> argument: $3\n"
exit
fi
PARENT_NODE_INDEX_BEGIN=$3
printf "PARENT_NODE_INDEX_BEGIN=$PARENT_NODE_INDEX_BEGIN\n"
if [[ $4 -lt 0 ]] || [[ $4 -gt 4 ]]; then
printf "Invalid <Parent Node Index End> argument: $4\n"
exit
fi
PARENT_NODE_INDEX_END=$4
printf "PARENT_NODE_INDEX_END=$PARENT_NODE_INDEX_END\n"
printf "\n"
Expand Down
2 changes: 1 addition & 1 deletion deploy_blockchain_incremental_gcp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ function deploy_node() {

# 5. Wait until node is synced
printf "\n\n<<< Waiting until node $node_index is synced >>>\n\n"
WAIT_CMD="gcloud compute ssh $node_target_addr --command 'cd \$(find /home/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh' --project $PROJECT_ID --zone $node_zone"
WAIT_CMD="gcloud compute ssh $node_target_addr --command 'cd \$(find /home/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh $node_url' --project $PROJECT_ID --zone $node_zone"
printf "WAIT_CMD=$WAIT_CMD\n\n"
eval $WAIT_CMD
}
Expand Down
10 changes: 9 additions & 1 deletion deploy_blockchain_incremental_onprem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ if [[ ! $2 =~ $number_re ]] ; then
printf "Invalid <# of Shards> argument: $2\n"
exit
fi
if [[ $3 -lt 0 ]] || [[ $3 -gt 4 ]]; then
printf "Invalid <Parent Node Index Begin> argument: $3\n"
exit
fi
PARENT_NODE_INDEX_BEGIN=$3
printf "PARENT_NODE_INDEX_BEGIN=$PARENT_NODE_INDEX_BEGIN\n"
if [[ $4 -lt 0 ]] || [[ $4 -gt 4 ]]; then
printf "Invalid <Parent Node Index End> argument: $4\n"
exit
fi
PARENT_NODE_INDEX_END=$4
printf "PARENT_NODE_INDEX_END=$PARENT_NODE_INDEX_END\n"
printf "\n"
Expand Down Expand Up @@ -339,7 +347,7 @@ function deploy_node() {
# 5. Wait until node is synced
printf "\n\n<<< Waiting until node $node_index ($node_target_addr) is synced >>>\n\n"

WAIT_CMD="ssh $node_target_addr 'cd \$(find /home/${SEASON}/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh'"
WAIT_CMD="ssh $node_target_addr 'cd \$(find /home/${SEASON}/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh $node_url'"
printf "\n\nWAIT_CMD=$WAIT_CMD\n\n"
eval "echo ${node_login_pw} | sshpass -f <(printf '%s\n' ${node_login_pw}) ${WAIT_CMD}"
}
Expand Down
15 changes: 13 additions & 2 deletions wait_until_node_sync.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#!/bin/bash

if [[ $# -lt 1 ]] || [[ $# -gt 1 ]]; then
printf "Usage: bash wait_until_node_sync.sh <Blockchain Node Url>\n"
printf "Example: bash wait_until_node_sync.sh http://123.456.789.1:8079\n"
printf "\n"
return 1
fi

printf "\n[[[[[ wait_until_node_sync.sh ]]]]]\n\n"

# Parse options.
NODE_URL="$1"
printf "NODE_URL=$NODE_URL\n"

printf "\n#### Wait until the new node server catches up ####\n\n"

SECONDS=0
Expand All @@ -16,11 +27,11 @@ EOF

while :
do
healthCheck=$(curl -m 20 -X GET -H "Content-Type: application/json" "http://localhost:8080/health_check")
healthCheck=$(curl -m 20 -X GET -H "Content-Type: application/json" "${NODE_URL}/health_check")
printf "\nhealthCheck = ${healthCheck}\n"
if [[ "$healthCheck" = "true" ]]; then
printf "\nBlockchain Node server is synced & running!\n"
lastBlockNumber=$(curl -m 20 -X GET -H "Content-Type: application/json" "http://localhost:8080/last_block_number" | jq -r '.result')
lastBlockNumber=$(curl -m 20 -X GET -H "Content-Type: application/json" "${NODE_URL}/last_block_number" | jq -r '.result')
printf "\nlastBlockNumber = ${lastBlockNumber}\n"
printf "\nTime it took to sync in seconds: $SECONDS\n"
break
Expand Down
Loading