Skip to content

Commit 9ea4fd6

Browse files
authored
Merge pull request #1322 from ainblockchain/bugfix/platfowner/bugfix
Update wait_until_node_sync.sh accept custom for custom ports
2 parents e3dc953 + ca1918b commit 9ea4fd6

4 files changed

+31
-4
lines changed

deploy_blockchain_genesis_onprem.sh

+8
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ if [[ ! $2 =~ $number_re ]] ; then
2929
printf "Invalid <# of Shards> argument: $2\n"
3030
exit
3131
fi
32+
if [[ $3 -lt 0 ]] || [[ $3 -gt 4 ]]; then
33+
printf "Invalid <Parent Node Index Begin> argument: $3\n"
34+
exit
35+
fi
3236
PARENT_NODE_INDEX_BEGIN=$3
3337
printf "PARENT_NODE_INDEX_BEGIN=$PARENT_NODE_INDEX_BEGIN\n"
38+
if [[ $4 -lt 0 ]] || [[ $4 -gt 4 ]]; then
39+
printf "Invalid <Parent Node Index End> argument: $4\n"
40+
exit
41+
fi
3442
PARENT_NODE_INDEX_END=$4
3543
printf "PARENT_NODE_INDEX_END=$PARENT_NODE_INDEX_END\n"
3644
printf "\n"

deploy_blockchain_incremental_gcp.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ function deploy_node() {
352352

353353
# 5. Wait until node is synced
354354
printf "\n\n<<< Waiting until node $node_index is synced >>>\n\n"
355-
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"
355+
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"
356356
printf "WAIT_CMD=$WAIT_CMD\n\n"
357357
eval $WAIT_CMD
358358
}

deploy_blockchain_incremental_onprem.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ if [[ ! $2 =~ $number_re ]] ; then
2929
printf "Invalid <# of Shards> argument: $2\n"
3030
exit
3131
fi
32+
if [[ $3 -lt 0 ]] || [[ $3 -gt 4 ]]; then
33+
printf "Invalid <Parent Node Index Begin> argument: $3\n"
34+
exit
35+
fi
3236
PARENT_NODE_INDEX_BEGIN=$3
3337
printf "PARENT_NODE_INDEX_BEGIN=$PARENT_NODE_INDEX_BEGIN\n"
38+
if [[ $4 -lt 0 ]] || [[ $4 -gt 4 ]]; then
39+
printf "Invalid <Parent Node Index End> argument: $4\n"
40+
exit
41+
fi
3442
PARENT_NODE_INDEX_END=$4
3543
printf "PARENT_NODE_INDEX_END=$PARENT_NODE_INDEX_END\n"
3644
printf "\n"
@@ -339,7 +347,7 @@ function deploy_node() {
339347
# 5. Wait until node is synced
340348
printf "\n\n<<< Waiting until node $node_index ($node_target_addr) is synced >>>\n\n"
341349

342-
WAIT_CMD="ssh $node_target_addr 'cd \$(find /home/${SEASON}/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh'"
350+
WAIT_CMD="ssh $node_target_addr 'cd \$(find /home/${SEASON}/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh $node_url'"
343351
printf "\n\nWAIT_CMD=$WAIT_CMD\n\n"
344352
eval "echo ${node_login_pw} | sshpass -f <(printf '%s\n' ${node_login_pw}) ${WAIT_CMD}"
345353
}

wait_until_node_sync.sh

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#!/bin/bash
22

3+
if [[ $# -lt 1 ]] || [[ $# -gt 1 ]]; then
4+
printf "Usage: bash wait_until_node_sync.sh <Blockchain Node Url>\n"
5+
printf "Example: bash wait_until_node_sync.sh http://123.456.789.1:8079\n"
6+
printf "\n"
7+
return 1
8+
fi
9+
310
printf "\n[[[[[ wait_until_node_sync.sh ]]]]]\n\n"
411

12+
# Parse options.
13+
NODE_URL="$1"
14+
printf "NODE_URL=$NODE_URL\n"
15+
516
printf "\n#### Wait until the new node server catches up ####\n\n"
617

718
SECONDS=0
@@ -16,11 +27,11 @@ EOF
1627

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

0 commit comments

Comments
 (0)