Last active
March 7, 2024 17:08
-
-
Save rgl/f90ff293d56dbb0a1e0f7e7e89a81f42 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 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
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done' | |
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76 |
There is https://github.com/nev7n/wait_for_response, however, that doesn't support all the options available in curl.
Hi all,
Here a solution that worked to me. In my case I used it for an initContainer:
sh -c 'while (( curl -s -o /dev/null -w %{http_code} https://google.com/ != "200" && curl -s -o /dev/null -w %{http_code} https://google.com/ != "301")); do sleep 1; done;'
Thanks!
I forked your version and extended it to a script that can be used right away. We use it in the CI to wait for services until they are available.
https://gist.github.com/eisenreich/195ab1f05715ec86e300f75d007d711c
There is https://github.com/nev7n/wait_for_response, however, that doesn't support all the options available in curl.
Thank you that looks neat
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! Hope someone could make it to be a github action.