-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add script that is used to wait for the hub to become available
- Loading branch information
1 parent
79f35a2
commit ea6ac5b
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "$@" |