From 81e19c10fa2fc20a37f52367d64496110ebe903a Mon Sep 17 00:00:00 2001 From: Michal Budzyn Date: Fri, 10 Mar 2017 21:59:16 +0100 Subject: [PATCH] support listeners in --env --- kafka/scripts/start-kafka.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kafka/scripts/start-kafka.sh b/kafka/scripts/start-kafka.sh index 168fc97..2adc8d1 100755 --- a/kafka/scripts/start-kafka.sh +++ b/kafka/scripts/start-kafka.sh @@ -3,6 +3,7 @@ # Optional ENV variables: # * ADVERTISED_HOST: the external ip for the container, e.g. `docker-machine ip \`docker-machine active\`` # * ADVERTISED_PORT: the external port for Kafka, e.g. 9092 +# * LISTENERS: configure the listener list e.g. "PLAINTEXT://:9092" # * ZK_CHROOT: the zookeeper chroot that's used by Kafka (without / prefix), e.g. "kafka" # * LOG_RETENTION_HOURS: the minimum age of a log file in hours to be eligible for deletion (default is 168, for 1 week) # * LOG_RETENTION_BYTES: configure the size at which segments are pruned from the log, (default is 1073741824, for 1GB) @@ -32,6 +33,16 @@ if [ ! -z "$ADVERTISED_PORT" ]; then fi fi +# Set the listener list +if [ ! -z "$LISTENERS" ]; then + echo "listeners : $LISTENERS" + if grep -q "^listeners" $KAFKA_HOME/config/server.properties; then + sed -r -i "s/#(listeners)=(.*)/\1=$(echo $LISTENERS | sed -e 's/[\/&]/\\&/g')/g" $KAFKA_HOME/config/server.properties + else + echo "listeners=$LISTENERS" >> $KAFKA_HOME/config/server.properties + fi +fi + # Set the zookeeper chroot if [ ! -z "$ZK_CHROOT" ]; then # wait for zookeeper to start up