Created
March 30, 2021 06:39
-
-
Save ramhoj/2190cf3ce4af2cdbbb30f88a879ddce7 to your computer and use it in GitHub Desktop.
wait_for_elasticsearch.sh
This file contains hidden or 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
#!/usr/bin/env bash | |
# Credit: https://stackoverflow.com/a/59795634/1686364 | |
host="localhost:9200" | |
response="" | |
attempt=0 | |
until [ "$response" = "200" ]; do | |
if [ $attempt -ge 25 ]; then | |
echo "FAILED. Elasticsearch not responding after $attempt tries." | |
exit 1 | |
fi | |
echo "Contacting Elasticsearch on ${host}. Try number ${attempt}" | |
response=$(curl --write-out %{http_code} --silent --output /dev/null "$host") | |
sleep 1 | |
attempt=$[$attempt+1] | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment