Wait for nitro contracts to become available
This commit is contained in:
parent
a31ad1d452
commit
8f2f791960
@ -5,9 +5,6 @@ services:
|
||||
depends_on:
|
||||
ipld-eth-db:
|
||||
condition: service_healthy
|
||||
# Wait for Nitro contracts to be deployed
|
||||
nitro-contracts:
|
||||
condition: service_completed_successfully
|
||||
image: cerc/ipld-eth-server:local
|
||||
environment:
|
||||
SERVER_HTTP_PATH: 0.0.0.0:8081
|
||||
|
||||
@ -29,12 +29,13 @@ fi
|
||||
|
||||
echo "Running Nitro node"
|
||||
|
||||
# Assuming CERC_NITRO_CHAIN_URL is of format <ws|http>://host:port
|
||||
ws_host=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 1)
|
||||
ws_port=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 2)
|
||||
|
||||
# Wait till chain endpoint is available
|
||||
retry_interval=5
|
||||
while true; do
|
||||
# Assuming CERC_NITRO_CHAIN_URL is of format <ws|http>://host:port
|
||||
ws_host=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 1)
|
||||
ws_port=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 2)
|
||||
nc -z -w 1 "$ws_host" "$ws_port"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
@ -12,34 +12,25 @@ if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||
export NITRO_NA_ADDRESS=${CERC_NA_ADDRESS}
|
||||
export NITRO_VPA_ADDRESS=${CERC_VPA_ADDRESS}
|
||||
export NITRO_CA_ADDRESS=${CERC_CA_ADDRESS}
|
||||
elif [ -f ${nitro_addresses_file} ]; then
|
||||
echo "Reading Nitro addresses from ${nitro_addresses_file}"
|
||||
|
||||
export NITRO_NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${nitro_addresses_file})
|
||||
export NITRO_VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${nitro_addresses_file})
|
||||
export NITRO_CA_ADDRESS=$(jq -r '.consensusAppAddress' ${nitro_addresses_file})
|
||||
else
|
||||
echo "File ${nitro_addresses_file} not found"
|
||||
exit 1
|
||||
# Read addresses from a file
|
||||
# Keep retrying until found
|
||||
echo "Reading Nitro addresses from ${nitro_addresses_file}"
|
||||
retry_interval=5
|
||||
while true; do
|
||||
if [[ -e "$nitro_addresses_file" ]]; then
|
||||
export NITRO_NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${nitro_addresses_file})
|
||||
export NITRO_VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${nitro_addresses_file})
|
||||
export NITRO_CA_ADDRESS=$(jq -r '.consensusAppAddress' ${nitro_addresses_file})
|
||||
|
||||
break
|
||||
else
|
||||
echo "File not yet available, retrying in $retry_interval seconds..."
|
||||
sleep $retry_interval
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Wait till chain endpoint is available
|
||||
retry_interval=5
|
||||
while true; do
|
||||
# Assuming NITRO_CHAIN_URL is of format <ws|http>://host:port
|
||||
ws_host=$(echo "$NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 1)
|
||||
ws_port=$(echo "$NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 2)
|
||||
nc -z -w 1 "$ws_host" "$ws_port"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Chain endpoint is available"
|
||||
break
|
||||
fi
|
||||
|
||||
echo "Chain endpoint not yet available, retrying in $retry_interval seconds..."
|
||||
sleep $retry_interval
|
||||
done
|
||||
|
||||
echo "Beginning the ipld-eth-server process"
|
||||
|
||||
START_CMD="./ipld-eth-server"
|
||||
|
||||
@ -43,3 +43,4 @@ nitro-contracts
|
||||
nitro-reverse-payment-proxy
|
||||
mobymask-snap
|
||||
ponder
|
||||
ipld-eth-server-payments
|
||||
|
||||
Loading…
Reference in New Issue
Block a user