Last active
January 26, 2019 08:25
-
-
Save rmetzler/879ba451d707984e51db9019d6c15391 to your computer and use it in GitHub Desktop.
waiting for http
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
function wait_for_http_200_ok(){ | |
URL="$1" | |
timeout="$((SECONDS+60))" | |
while true; do | |
HTTP_CODE=$( curl --silent --write-out %{http_code} --output /dev/null ${URL} ) | |
[[ "200" = "$HTTP_CODE" ]] && break | |
[[ "${SECONDS}" -ge "${timeout}" ]] && echo "timed out waiting for ${URL}" && exit 1 | |
sleep 1 | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment