2023-10-13 09:57:17 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-10-18 08:21:55 +00:00
|
|
|
read_nitro_addresses() {
|
|
|
|
nitro_addresses_file="/app/deployment/nitro-addresses.json"
|
|
|
|
|
|
|
|
# Check if CERC_NA_ADDRESS environment variable is set
|
|
|
|
if [ -n "$CERC_NA_ADDRESS" ]; then
|
|
|
|
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
|
|
|
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
|
|
|
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
|
|
|
|
echo "Using the above Nitro addresses"
|
|
|
|
|
|
|
|
export NITRO_NA_ADDRESS=${CERC_NA_ADDRESS}
|
|
|
|
export NITRO_VPA_ADDRESS=${CERC_VPA_ADDRESS}
|
|
|
|
export NITRO_CA_ADDRESS=${CERC_CA_ADDRESS}
|
|
|
|
else
|
|
|
|
# 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_for_nitro_endpoint() {
|
2023-10-14 04:17:55 +00:00
|
|
|
retry_interval=5
|
|
|
|
while true; do
|
2023-10-18 08:21:55 +00:00
|
|
|
curl -I -s -o /dev/null $NITRO_ENDPOINT/health
|
2023-10-14 04:17:55 +00:00
|
|
|
|
2023-10-18 08:21:55 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Nitro endpoint is up"
|
2023-10-14 04:17:55 +00:00
|
|
|
break
|
|
|
|
else
|
2023-10-18 08:21:55 +00:00
|
|
|
echo "Nitro endpoint not available yet, retrying in $retry_interval seconds..."
|
2023-10-14 04:17:55 +00:00
|
|
|
sleep $retry_interval
|
|
|
|
fi
|
|
|
|
done
|
2023-10-18 08:21:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$NITRO_RUN_NODE_IN_PROCESS" = "true" ]; then
|
|
|
|
read_nitro_addresses
|
|
|
|
else
|
|
|
|
wait_for_nitro_endpoint
|
2023-10-13 09:57:17 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Beginning the ipld-eth-server process"
|
|
|
|
|
|
|
|
START_CMD="./ipld-eth-server"
|
|
|
|
if [ "true" == "$CERC_REMOTE_DEBUG" ] && [ -x "/usr/local/bin/dlv" ]; then
|
|
|
|
START_CMD="/usr/local/bin/dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec `pwd`/ipld-eth-server --continue --"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo running: $START_CMD ${VDB_COMMAND} --config=`pwd`/config.toml
|
|
|
|
$START_CMD ${VDB_COMMAND} --config=`pwd`/config.toml
|
|
|
|
rv=$?
|
|
|
|
|
|
|
|
if [ $rv != 0 ]; then
|
|
|
|
echo "ipld-eth-server startup failed"
|
|
|
|
exit 1
|
|
|
|
fi
|