-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwait_for_es.sh
More file actions
executable file
·23 lines (19 loc) · 886 Bytes
/
wait_for_es.sh
File metadata and controls
executable file
·23 lines (19 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
host="$1"
# First wait for ES to start...
response=$(curl --write-out %{http_code} --silent --output /dev/null "$host")
until [ "$response" = "200" ]; do
response=$(curl --write-out %{http_code} --silent --output /dev/null "$host")
>&2 echo "Waiting for ElasticSearch to boot up..."
sleep 1
done
# next wait for ES status to turn to Yellow
health="$(curl -fsSL "$host/_cat/health?h=status")"
health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "yellow ")
until [[ "$health" = 'yellow' || "$health" = "green" ]]; do
health="$(curl -fsSL "$host/_cat/health?h=status")"
health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "yellow ")
>&2 echo "Waiting for ElasticSearch to boot up..."
sleep 1
done
>&2 echo "ElasticSearch is up"