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