From dab409f64953c07d04b7459be8bebf3de721fec9 Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:02:27 +0100 Subject: [PATCH] be more fault tolerant --- upstreams.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/upstreams.sh b/upstreams.sh index 1860347f..fdc22513 100755 --- a/upstreams.sh +++ b/upstreams.sh @@ -56,8 +56,20 @@ for part in "${parts[@]}"; do fi export PROVIDER=${ORGANIZATION}-${ID} + + response_file=$(mktemp) + + http_status_code=$(curl --ipv4 -m 5 -s -o "$response_file" -w "%{http_code}" -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' $TEST_URL) + + if [ $? -eq 0 ] && [[ $http_status_code -ne 200 ]]; then + echo "have error response from $TEST_URL: $(cat $response_file)" >&2 + rm "$response_file" + continue # Skip to the next iteration of the loop + fi + + chain_id=$(cat "$response_file" | jq -r '.result') + rm "$response_file" - chain_id=$(curl --ipv4 -m 1 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' $TEST_URL | jq -r '.result') #echo "$TEST_URL $chain_id" >&2 chain_id_decimal=$((16#${chain_id#0x})) export CHAIN=$($BASEPATH/get-shortname.sh $chain_id_decimal)