Skip to content

Commit 687ac2d

Browse files
author
Romain GÉRARD
committed
Docker: Waiting for jmx port to be open before starting the exporter
1 parent e1fe4dd commit 687ac2d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

docker/Dockerfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
FROM openjdk:10.0.1-10-jre-slim-sid
1+
FROM openjdk:10.0.2-13-jre-slim-sid
22

33
ARG EXPORTER_VERSION=2.0.0
44
ARG EXPORTER_SHA512=7baa4e13f0a3c4228ba9d6cb848027f8837de0a0bc2a6b4fc3d8265e00a53fe926a6eac75a32a84de5e0771b355c1a8715dd46886c134710c6f26f477010b9d3
55

6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
netcat \
8+
&& apt-get clean \
9+
&& rm -rf /var/lib/apt/lists/*
10+
611
RUN mkdir -p /etc/cassandra_exporter /opt/cassandra_exporter
712
ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64 /sbin/dumb-init
813
ADD https://github.com/criteo/cassandra_exporter/releases/download/${EXPORTER_VERSION}/cassandra_exporter-${EXPORTER_VERSION}-all.jar /opt/cassandra_exporter/cassandra_exporter.jar

docker/run.sh

+8
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,12 @@ while IFS='=' read -r name value ; do
2020
fi
2121
done < <(env)
2222

23+
host=$(grep -m1 'host:' /etc/cassandra_exporter/config.yml | cut -d ':' -f2)
24+
port=$(grep -m1 'host:' /etc/cassandra_exporter/config.yml | cut -d ':' -f3)
25+
26+
while ! nc -z $host $port; do
27+
echo "Waiting for Cassandra JMX to start on $host:$port"
28+
sleep 1
29+
done
30+
2331
/sbin/dumb-init /usr/bin/java ${JVM_OPTS} -jar /opt/cassandra_exporter/cassandra_exporter.jar /etc/cassandra_exporter/config.yml

0 commit comments

Comments
 (0)