Added wait-cluster script

This commit is contained in:
delvedor
2018-10-30 18:36:04 +01:00
parent 3962e2c031
commit a60ac39aa6

19
scripts/wait-cluster.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
attempt_counter=0
max_attempts=5
url='http://localhost:9200/_cluster/health?wait_for_status=green&timeout=50s'
echo "Waiting for Elasticsearch..."
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' --max-time 55 "$url")" != "200" ]]; do
if [ ${attempt_counter} -eq ${max_attempts} ];then
echo "\nCouldn't connect to Elasticsearch"
exit 1
fi
printf '.'
attempt_counter=$(($attempt_counter+1))
sleep 5
done
echo "\nReady"