Skip to content

Commit

Permalink
Docker: Waiting for jmx port to be open before starting the exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain GÉRARD committed Sep 18, 2018
1 parent e1fe4dd commit 687ac2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM openjdk:10.0.1-10-jre-slim-sid
FROM openjdk:10.0.2-13-jre-slim-sid

ARG EXPORTER_VERSION=2.0.0
ARG EXPORTER_SHA512=7baa4e13f0a3c4228ba9d6cb848027f8837de0a0bc2a6b4fc3d8265e00a53fe926a6eac75a32a84de5e0771b355c1a8715dd46886c134710c6f26f477010b9d3

RUN apt-get update && apt-get install -y --no-install-recommends \
netcat \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /etc/cassandra_exporter /opt/cassandra_exporter
ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64 /sbin/dumb-init
ADD https://github.com/criteo/cassandra_exporter/releases/download/${EXPORTER_VERSION}/cassandra_exporter-${EXPORTER_VERSION}-all.jar /opt/cassandra_exporter/cassandra_exporter.jar
Expand Down
8 changes: 8 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ while IFS='=' read -r name value ; do
fi
done < <(env)

host=$(grep -m1 'host:' /etc/cassandra_exporter/config.yml | cut -d ':' -f2)
port=$(grep -m1 'host:' /etc/cassandra_exporter/config.yml | cut -d ':' -f3)

while ! nc -z $host $port; do
echo "Waiting for Cassandra JMX to start on $host:$port"
sleep 1
done

/sbin/dumb-init /usr/bin/java ${JVM_OPTS} -jar /opt/cassandra_exporter/cassandra_exporter.jar /etc/cassandra_exporter/config.yml

0 comments on commit 687ac2d

Please sign in to comment.