From 69a30628b1104e9c774f636cbe0987b6a9e67320 Mon Sep 17 00:00:00 2001 From: Ivaylo Novakov Date: Tue, 11 May 2021 16:02:48 +0200 Subject: [PATCH] Use a simpler wait_to_start script. --- docker-compose.jaeger.yml | 16 ++++++++++++---- packages/wait_to_start/wait_to_start.sh | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100755 packages/wait_to_start/wait_to_start.sh diff --git a/docker-compose.jaeger.yml b/docker-compose.jaeger.yml index 3a1c29dc..40392ced 100644 --- a/docker-compose.jaeger.yml +++ b/docker-compose.jaeger.yml @@ -33,7 +33,7 @@ services: jaeger-collector: image: jaegertracing/jaeger-collector - command: [ "/wait-for-it/wait-for-it.sh", "elasticsearch:9200", "--", "--es.num-shards=1", "--es.num-replicas=0", "--es.server-urls=http://elasticsearch:9200" ] + entrypoint: /wait_to_start/wait_to_start.sh container_name: jaeger-collector restart: on-failure expose: @@ -43,8 +43,12 @@ services: environment: - SPAN_STORAGE_TYPE=elasticsearch - LOG_LEVEL=debug + - WAIT_START_CMD=/go/bin/collector-linux --es.num-shards=1 --es.num-replicas=0 --es.server-urls=http://elasticsearch:9200 + - WAIT_COMMAND=wget -O index.html http://elasticsearch:9200 + - WAIT_SLEEP=1 + - WAIT_LOOPS=600 volumes: - - ./packages/wait-for-it:/wait-for-it + - ./packages/wait_to_start:/wait_to_start networks: shared: ipv4_address: 10.10.10.91 @@ -53,7 +57,7 @@ services: jaeger-query: image: jaegertracing/jaeger-query - command: [ "/wait-for-it/wait-for-it.sh", "elasticsearch:9200", "--", "--es.num-shards=1", "--es.num-replicas=0", "--es.server-urls=http://elasticsearch:9200" ] + entrypoint: /wait_to_start/wait_to_start.sh container_name: jaeger-query restart: on-failure ports: @@ -63,8 +67,12 @@ services: environment: - SPAN_STORAGE_TYPE=elasticsearch - LOG_LEVEL=debug + - WAIT_START_CMD=/go/bin/query-linux --es.num-shards=1 --es.num-replicas=0 --es.server-urls=http://elasticsearch:9200 + - WAIT_COMMAND=wget -O index.html http://elasticsearch:9200 + - WAIT_SLEEP=1 + - WAIT_LOOPS=600 volumes: - - ./packages/wait-for-it:/wait-for-it + - ./packages/wait_to_start:/wait_to_start networks: shared: ipv4_address: 10.10.10.92 diff --git a/packages/wait_to_start/wait_to_start.sh b/packages/wait_to_start/wait_to_start.sh new file mode 100755 index 00000000..c56d273f --- /dev/null +++ b/packages/wait_to_start/wait_to_start.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +echo $WAIT_COMMAND +echo $WAIT_START_CMD + +is_ready() { + eval "$WAIT_COMMAND" +} + +# wait until is ready +i=0 +while ! is_ready; do + i=`expr $i + 1` + if [ $i -ge $WAIT_LOOPS ]; then + echo "$(date) - still not ready, giving up" + exit 1 + fi + echo "$(date) - waiting to be ready" + sleep $WAIT_SLEEP +done + +#start the script +exec $WAIT_START_CMD