-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo_setup.sh
executable file
·66 lines (60 loc) · 2.38 KB
/
demo_setup.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
## Functions
setupStreams() {
echo test $KAFKA_HOME
if [ -z $KAFKA_HOME ]; then
echo 'Missing KAFKA_HOME env var'
exit 1;
fi
trap "exit 1" SIGINT SIGTERM
# ZooKeeper & Kafka
cleanup
echo $KAFKA_HOME
cd $KAFKA_HOME/bin
./zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties &
sleep 1
./kafka-server-start.sh $KAFKA_HOME/config/server.properties &
sleep 2
topics
sleep 1
echo 'Demo Kafka ready ...'
}
setupDocker() {
if [ -z $KAFKA_HOME ]; then
echo 'Missing KAFKA_HOME env var'
exit 1;
fi
echo $KAFKA_HOME
cd $KAFKA_HOME/bin
topics
echo 'Demo Kafka Docker ready ...'
}
topics() {
./kafka-topics.sh --zookeeper localhost --create --topic storage-topic --partitions 1 --replication-factor 1 --config cleanup.policy=compact
./kafka-topics.sh --zookeeper localhost --create --topic global-id-topic --partitions 1 --replication-factor 1 --config cleanup.policy=compact
./kafka-topics.sh --zookeeper localhost --create --topic input-topic --partitions 1 --replication-factor 1 --config cleanup.policy=compact
./kafka-topics.sh --zookeeper localhost --create --topic logx-topic --partitions 1 --replication-factor 1 --config cleanup.policy=compact
./kafka-topics.sh --zookeeper localhost --create --topic dbx-topic --partitions 1 --replication-factor 1 --config cleanup.policy=compact
./kafka-topics.sh --zookeeper localhost --create --topic transrec --partitions 1 --replication-factor 1 --config cleanup.policy=compact
./kafka-topics.sh --zookeeper localhost --create --topic webtrans --partitions 1 --replication-factor 1 --config cleanup.policy=compact
./kafka-topics.sh --zookeeper localhost --create --topic transrec-quarkus --partitions 1 --replication-factor 1 --config cleanup.policy=compact
./kafka-topics.sh --zookeeper localhost --create --topic webtrans-quarkus --partitions 1 --replication-factor 1 --config cleanup.policy=compact
}
cleanup() {
ps -ax | grep kafka | awk '{print $1}' | xargs kill -9
ps -ax | grep zookeeper | awk '{print $1}' | xargs kill -9
rm -rf /tmp/zookeeper/
rm -rf /tmp/kafka-*
}
## Main
if [ -z $1 ]; then
echo 'Setting-up Demo Kafka ...'
setupStreams
elif [ "$1" == "cleanup" ]
then
echo 'Demo Kafka cleanup ...'
cleanup
elif [ "$1" == "docker" ]
then
echo 'Demo Kafka Docker ...'
setupDocker
fi