Welcome to mirror list, hosted at ThFree Co, Russian Federation.

wait-for-elasticsearch.sh « elastic_stack « vendor - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1423af2e10b1e63659cf219f883580aed0fd13b1 (plain)
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
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
IFS=$'\n\t'
set -euo pipefail

HOST="$1"

printf 'Waiting for ES to be reachable ...'
until $(wget -O- -q "$HOST" &>/dev/null); do
    printf '.'
    sleep 1
done
echo " OK!"

printf 'Waiting for ES to be healthy ...'
while : ; do
    HEALTH="$(wget -O- -q "$HOST/_cat/health?h=status" 2> /dev/null)"
    HEALTH="$(echo "$HEALTH" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ")
    ([ "$HEALTH" != "green" ] && printf '.' && sleep 1) || break
done
echo " OK!"

echo "Elastic Search is up!"