Created
January 20, 2020 16:57
-
-
Save Gameghostify/8cc9eb93d0ef0cdc9bf66aa97ab15049 to your computer and use it in GitHub Desktop.
Wait until a web service is up and accepts connections
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
#!/bin/sh | |
### not needed | |
echo "$(tput setaf 3)waiting for api service to accept connections$(tput sgr0)" | |
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - | |
### | |
api_service_url="http://localhost:8080" # FIXME enter correct url | |
attempt_counter=0 | |
max_attempts=20 | |
until [ $(curl -s -o /dev/null -w "%{http_code}" $api_service_url) -ne 000 ]; do | |
if [ ${attempt_counter} -eq ${max_attempts} ];then | |
echo "Unable to ping api service, aborting" | |
exit 1 | |
fi | |
printf '.' | |
attempt_counter=$(($attempt_counter+1)) | |
sleep 3 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment