-
-
Save dtelaroli/c6aa76033a0d2ab0c001951846200519 to your computer and use it in GitHub Desktop.
Wait for an HTTP endpoint to return 200 OK with Bash and curl
This file contains hidden or 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
#!/bin/bash | |
# Usage | |
# $ chmod +x ./wait_for_http_200.sh | |
# $ sh wait_for_http_200.sh http://<host>:<port>/<path> | |
echo "Trying to reach ${1}" | |
i=0 | |
while [[ "$(curl -s -o /dev/null -w '%{http_code}' ${1})" != "200" ]]; do | |
sleep 5 | |
let "i+=5" | |
echo "Trying again after ${i} seconds. Press Ctrl + C to cancel." | |
done | |
echo 'Service OK' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment