Created
January 4, 2017 13:33
-
-
Save JensRantil/1576cc7b7e33cb8d9e0c0d582323544f to your computer and use it in GitHub Desktop.
Elasticsearch upstart sample for safe shutdown (for unattended security updates etc.)
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
description "Elastic Search" | |
pre-stop script | |
triesleft=3600 | |
while true | |
do | |
curl -s localhost:9200/_cluster/health?pretty | grep status | grep green > /dev/null | |
exitcode=$? | |
#echo $exitcode | |
if [ $exitcode -ne 0 ] | |
then | |
echo "Status is not green." | |
sleep 10 | |
else | |
echo "Status is green." | |
break | |
fi | |
triesleft=$((triesleft-1)) | |
if [ $triesleft -eq 0 ] | |
then | |
echo "Tried for an hour. Restarting anyway." | |
break | |
fi | |
done | |
end script | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment