Skip to content

Instantly share code, notes, and snippets.

@rmetzler
Last active January 26, 2019 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmetzler/879ba451d707984e51db9019d6c15391 to your computer and use it in GitHub Desktop.
Save rmetzler/879ba451d707984e51db9019d6c15391 to your computer and use it in GitHub Desktop.
waiting for http
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