Skip to content

Commit

Permalink
feat: add script that is used to wait for the hub to become available
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs committed Feb 19, 2024
1 parent 79f35a2 commit ea6ac5b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/fraud_proof_poc/wait-for-hub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Target URL
URL="http://hub:36657/status"

# Wait for the /status endpoint to be available and the latest_block_height to be present
while true; do
# Use curl to fetch the status endpoint and jq to parse the JSON response
HEIGHT=$(curl -s $URL | jq -r '.result.sync_info.latest_block_height')

# Check if HEIGHT is a number and greater than 0 (modify this check as needed)
if [[ "$HEIGHT" =~ ^[0-9]+$ ]] && [ "$HEIGHT" -gt 0 ]; then
echo "hub is ready with latest_block_height: $HEIGHT"
break
else
echo "Waiting for hub to be ready..."
fi

sleep 5 # Wait for 5 seconds before trying again
done

# Proceed with the rest of your script or command to start the service
exec "$@"

0 comments on commit ea6ac5b

Please sign in to comment.