Last active
January 12, 2022 14:05
-
-
Save LeeCheneler/d4f20a272f95b16d5118a35853f35973 to your computer and use it in GitHub Desktop.
Wait for server to respond, useful in pipeline to wait for service or app to start
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 | |
START=$(date '+%s') | |
TIMEOUT=$(($START + 30)) | |
echo "Waiting for server $1 to start..." | |
until $(curl --output /dev/null --silent --head --insecure $1); do | |
NOW=$(date '+%s') | |
if [ "$NOW" -gt "$TIMEOUT" ]; then | |
echo "Server $1 failed to start in 30 seconds" | |
exit 1 | |
fi | |
sleep 1 | |
done | |
echo "Server $1 started" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment