forked from Blizzard/node-rdkafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_docker.sh
executable file
·42 lines (35 loc) · 911 Bytes
/
run_docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
COMPOSE_VERSION=$(docker-compose --version)
DOCKER_VERSION=$(docker --version)
# Start the docker compose file
echo "Running docker compose up. Docker version $DOCKER_VERSION. Compose version $COMPOSE_VERSION. "
docker-compose up -d
if [ "$?" == "1" ]; then
echo "Failed to start docker images."
exit 1
fi
# List of topics to create in container
topics=(
"test"
"test2"
"test3"
"test4"
"test5"
"test6"
)
# Run docker-compose exec to make them
for topic in "${topics[@]}"
do
echo "Making topic $topic"
until docker-compose exec kafka \
kafka-topics --create --topic $topic --partitions 1 --replication-factor 1 --if-not-exists --zookeeper zookeeper:2181
do
topic_result="$?"
if [ "$topic_result" == "1" ]; then
echo "Bad status code: $topic_result. Trying again."
else
# If it is some unknown status code, die.
exit 1
fi
done
done