-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·85 lines (74 loc) · 1.7 KB
/
run.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
function show_help {
cat <<EOF
Usage: run.sh [-a] [-b] [-k] [-c] [-p] [-x] [-h]
-a: Run all
-b: Build
-k: Run Kafka
-p: Run producer
-c: Run consumer
-x: Stops containers and clean data
-h: Shows this help
EOF
}
function build {
mvn package -T C1 && docker-compose build
}
function run_kafka {
docker-compose up -d zoo1 kafka1 kafdrop
until (echo dump | nc localhost 2181 | grep brokers); do sleep 1; done
kafka-topics --create --topic transcriptions -zookeeper localhost:2181 --replication-factor 1 --partitions 4
kafka-topics --create --topic transcription-states -zookeeper localhost:2181 --replication-factor 1 --partitions 4
kafka-topics --create --topic stateful-transcriptions -zookeeper localhost:2181 --replication-factor 1 --partitions 4
}
function run_producer {
docker-compose up -d kafka-producer
}
function run_consumer {
docker-compose up -d --scale kafka-consumer=4 kafka-consumer
}
function clean {
docker-compose stop
docker-compose rm -f
rm -rf zk-single-kafka-single
}
export DOCKER_HOST_IP=$(ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d\ -f2)
operations=()
while getopts "abkpPcCxh" OPTION; do
case $OPTION in
b)
operations+=(build)
;;
k)
operations+=(run_kafka)
;;
p)
operations+=(run_producer)
;;
c)
operations+=(run_consumer)
;;
x)
clean
exit 0
;;
h)
show_help
exit 0
;;
a)
operations=(build run_kafka run_producer run_consumer)
;;
*)
show_help
exit 1
;;
esac
done
if [ -z $operations ];then
show_help
exit 1
fi
for operation in ${operations[@]}; do
$operation
done