-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-assembly.sh
executable file
·48 lines (40 loc) · 1.19 KB
/
post-assembly.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
### Perform post-assembly tasks (common)
# Pass in the list of slave IPS.
# This also requires two envars:
# ES_PORT
# ES_VERSION
# Don't show progress bar, but do show errors
CURL_ARGS="-sS -f -L"
SLAVES=("$@")
declare -A status
for slave in ${SLAVES[@]}; do
status[$slave]="unknown"
done
check_status() {
for slave in ${SLAVES[@]}; do
if [[ ${status[$slave]} != "alive" ]]; then
return 1
fi
done
}
echo "Waiting for elasticsearch to come up on each slave..."
while ! check_status; do
for slave in ${SLAVES[@]}; do
if nc -w 5 $slave $ES_PORT </dev/null >/dev/null; then
if [[ ${status[$slave]} != alive ]]; then
echo "$slave is up on port $ES_PORT"
status[$slave]=alive
fi
else
if [[ ${status[$slave]} == alive ]]; then
echo "$slave has stopped responding on $ES_PORT"
status[$slave]=unknown
fi
fi
done
sleep 10
done
# We no longer need to set index caching preferences in ES v5
# Now get the status of the cluster from the first node
curl $CURL_ARGS -XGET http://${SLAVES[0]}:$ES_PORT/_cluster/state?pretty