File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 47
47
- run :
48
48
command : |
49
49
pushd metacpan-docker/src/metacpan-api
50
- ./wait-for-es.sh http://localhost:9200
50
+ ./wait-for-es.sh elasticsearch_test http://localhost:9200
51
51
name : wait for ES
52
52
- run :
53
53
command : |
Original file line number Diff line number Diff line change 5
5
6
6
set -ux
7
7
8
- host=" $1 "
8
+ container=" $1 "
9
+ host=" $2 "
10
+
11
+ preamble=" docker-compose exec $container "
9
12
10
13
while true ; do
11
- response=$( curl --write-out ' %{http_code}' --silent --fail --output /dev/null " $host " )
14
+ response=$( $preamble curl --write-out ' %{http_code}' --silent --fail --output /dev/null " $host " )
12
15
if [[ " $response " -eq " 200" ]]; then
13
16
break
14
17
fi
@@ -24,15 +27,13 @@ set -e
24
27
while true ; do
25
28
# # Wait for ES status to turn to yellow.
26
29
# # TODO: Ideally we'd be waiting for green, but we need multiple nodes for that.
27
- health=" $( curl -fsSL " $host /_cat/health?h=status" ) "
28
- health=" $( echo " $health " | xargs) " # trim whitespace (otherwise we'll have "green ")
29
- if [[ $health == ' yellow' || $health == ' green' ]]; then
30
+ health=$( $preamble curl -fsSL " $host /_cat/health?format=JSON" | jq ' .[0].status == "yellow" or .[0].status == "green"' )
31
+ if [[ $health == ' true' ]]; then
30
32
break
31
33
fi
32
34
echo " Elastic Search is unavailable ($health ) - sleeping" >&2
33
35
sleep 1
34
36
done
35
37
36
38
echo " Elastic Search is up" >&2
37
- shift
38
- exec " $@ "
39
+ exit 0
You can’t perform that action at this time.
0 commit comments