Created
July 21, 2017 02:39
-
-
Save aashreys/c2102814ac599dc788a20577b5383f64 to your computer and use it in GitHub Desktop.
A bash script which checks the status of a web server before executing commands.
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/bash | |
# wait-for-nlu.sh | |
set -e | |
host="$1" | |
shift | |
cmd="$@" | |
http_status="$(curl -s -o /dev/null -I -w "%{http_code}" http://www.webserver.com:8080/)" | |
while [ $http_status -ne 200 ] | |
do | |
>&2 echo "NLU service is unavailable - sleeping" | |
sleep 10 | |
http_status=http_status | |
done | |
>&2 echo "NLU service is up - executing command" | |
exec $cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment