#!/bin/bash
-IMAGE=juplo/rest-producer:1.0-SNAPSHOT
+IMAGE=juplo/rest-producer--json:1.0-SNAPSHOT
if [ "$1" = "cleanup" ]
then
- docker-compose down -v
+ docker-compose -f docker/docker-compose.yml down -t0 -v --remove-orphans
mvn clean
exit
fi
-docker-compose up -d zookeeper kafka cli
+docker-compose -f docker/docker-compose.yml up -d --remove-orphans kafka-1 kafka-2 kafka-3
+docker-compose -f docker/docker-compose.yml rm -svf producer producer-0 producer-1
if [[
$(docker image ls -q $IMAGE) == "" ||
"$1" = "build"
]]
then
- mvn install || exit
+ docker-compose rm -svf producer
+ mvn clean install || exit
else
echo "Using image existing images:"
docker image ls $IMAGE
fi
echo "Waiting for the Kafka-Cluster to become ready..."
-docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1
-docker-compose up setup
+docker-compose -f docker/docker-compose.yml run --rm cli cub kafka-ready -b kafka:9092 3 60 > /dev/null 2>&1 || exit 1
-docker-compose up -d
-
-sleep 15
-http :8081/status
-http :8082/status
-http :8083/status
-http :8084/status
-http :8085/status
-http :8000/seen
-
-http post :8081/stop
-http :8081/status
-http :8082/status
-http :8083/status
-http :8084/status
-http :8085/status
-http :8000/seen
-
-http post :8081/start
-
-sleep 1
-http :8081/status
-http :8082/status
-http :8083/status
-http :8084/status
-http :8085/status
-http :8000/seen
+docker-compose -f docker/docker-compose.yml up -t0 -d cli
sleep 1
-http :8081/status
-http :8082/status
-http :8083/status
-http :8084/status
-http :8085/status
-http :8000/seen
-sleep 1
-http :8081/status
-http :8082/status
-http :8083/status
-http :8084/status
-http :8085/status
-http :8000/seen
-sleep 1
-http :8081/status
-http :8082/status
-http :8083/status
-http :8084/status
-http :8085/status
-http :8000/seen
-sleep 1
-http :8081/status
-http :8082/status
-http :8083/status
-http :8084/status
-http :8085/status
-http :8000/seen
+docker-compose -f docker/docker-compose.yml logs setup
+
+docker-compose -f docker/docker-compose.yml up -d producer
+while ! [[ $(http 0:8080/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for producer..."; sleep 1; done
-http post :8081/stop
-http :8081/status
-http post :8082/stop
-http :8082/status
-http post :8083/stop
-http :8083/status
-http post :8084/stop
-http :8084/status
-http post :8085/stop
-http :8085/status
+docker-compose -f docker/docker-compose.yml up -d peter klaus
-http :8000/seen
-http post :8000/stop
+sleep 10
+docker-compose -f docker/docker-compose.yml stop peter klaus
-docker-compose logs producer
+# tag::kafkacat[]
+kafkacat -b :9092 -t test -o 0 -e -f 'p=%p|o=%o|k=%k|h=%h|v=%s\n'
+# end::kafkacat[]