forked from elodina/scala-kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-scala-go.sh
executable file
·28 lines (22 loc) · 1.05 KB
/
start-scala-go.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
#!/bin/sh
ZOOKEEPER=`docker ps -a | awk '{print $NF}' | grep "zookeeper$"`
ZOOKEEPER_RUNNING=$?
if [ $ZOOKEEPER_RUNNING -eq 0 ] ;
then
echo "Zookeeper is already running"
else
echo "Starting Zookeeper"
docker run --net=host --name zkserver -d stealthly/docker-zookeeper
fi
ID=1
PORT=9092
HOST_IP=localhost
docker run --net=host --name=broker$ID -p $PORT:$PORT -e BROKER_ID=$ID -e HOST_IP=$HOST_IP -e PORT=$PORT -d stealthly/docker-kafka
#let kafka initialize properly before establishing producers and consumers
sleep 10
go_topic=`head -c 100 /dev/urandom | base64 | sed 's/[+=/A-Z]//g' | tail -c 16`
scala_topic=`head -c 100 /dev/urandom | base64 | sed 's/[+=/A-Z]//g' | tail -c 16`
docker run --name scala --net=host -v $(pwd)/build/libs:/scala-kafka/build/libs -d stealthly/docker-java java -jar /scala-kafka/build/libs/scala-kafka-0.1.0.0.jar $scala_topic $go_topic
docker run --name golang --net=host -v $(pwd):/go-files -d golang:1.3.0 /go-files/run-go.sh $go_topic $scala_topic
# output logs to stdout
docker logs -f scala & docker logs -f golang &