4 if [[ -z "$START_TIMEOUT" ]]; then
8 start_timeout_exceeded=false
11 while netstat -lnt | awk '$4 ~ /:'$KAFKA_PORT'$/ {exit 1}'; do
12 echo "waiting for kafka to be ready"
14 count=$(expr $count + $step)
15 if [ $count -gt $START_TIMEOUT ]; then
16 start_timeout_exceeded=true
21 if $start_timeout_exceeded; then
22 echo "Not able to auto-create topic (waited for $START_TIMEOUT sec)"
26 if [[ -n $KAFKA_CREATE_TOPICS ]]; then
27 IFS=','; for topicToCreate in $KAFKA_CREATE_TOPICS; do
28 echo "creating topics: $topicToCreate"
29 IFS=':' read -a topicConfig <<< "$topicToCreate"
30 if [ ${topicConfig[3]} ]; then
31 JMX_PORT='' $KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper $KAFKA_ZOOKEEPER_CONNECT --replication-factor ${topicConfig[2]} --partitions ${topicConfig[1]} --topic "${topicConfig[0]}" --config cleanup.policy="${topicConfig[3]}" --if-not-exists
33 JMX_PORT='' $KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper $KAFKA_ZOOKEEPER_CONNECT --replication-factor ${topicConfig[2]} --partitions ${topicConfig[1]} --topic "${topicConfig[0]}" --if-not-exists