@@ -20,17 +20,42 @@ find ./build/confluent -maxdepth 1 -type d ! -wholename "./build/confluent" -exe
2020echo " Starting docker ."
2121docker-compose up -d --build
2222
23+ function clean_up {
24+ echo -e " \n\nSHUTTING DOWN\n\n"
25+ curl --output /dev/null -X DELETE http://localhost:8083/connectors/datagen-pageviews || true
26+ curl --output /dev/null -X DELETE http://localhost:8083/connectors/mongo-sink || true
27+ curl --output /dev/null -X DELETE http://localhost:8083/connectors/mongo-source || true
28+ docker-compose exec mongo1 /usr/bin/mongo --eval " db.dropDatabase()"
29+ docker-compose down
30+ if [ -z " $1 " ]
31+ then
32+ echo -e " Bye!\n"
33+ else
34+ echo -e $1
35+ fi
36+ }
37+
2338sleep 5
2439echo -ne " \n\nWaiting for the systems to be ready.."
25- until $( curl --output /dev/null --silent --head --fail http://localhost:8082) ; do
26- printf ' .'
27- sleep 1
28- done
40+ function test_systems_available {
41+ COUNTER=0
42+ until $( curl --output /dev/null --silent --head --fail http://localhost:$1 ) ; do
43+ printf ' .'
44+ sleep 2
45+ let COUNTER+=1
46+ if [[ $COUNTER -gt 10 ]]; then
47+ MSG=" \nWARNING: Could not reach configured kafka system on http://localhost:$1 \nNote: This script requires curl.\n"
48+ echo -e $MSG
49+ clean_up " $MSG "
50+ exit 1
51+ fi
52+ done
53+ }
2954
30- until $( curl --output /dev/null --silent --head --fail http://localhost:8083 ) ; do
31- printf ' . '
32- sleep 1
33- done
55+ test_systems_available 8082
56+ test_systems_available 8083
57+
58+ trap clean_up EXIT
3459
3560echo -e " \nConfiguring the MongoDB ReplicaSet.\n"
3661docker-compose exec mongo1 /usr/bin/mongo --eval ' ' ' if (rs.status()["ok"] == 0) {
@@ -47,16 +72,6 @@ docker-compose exec mongo1 /usr/bin/mongo --eval '''if (rs.status()["ok"] == 0)
4772
4873rs.conf();' ' '
4974
50- function finish {
51- curl --output /dev/null -X DELETE http://localhost:8083/connectors/datagen-pageviews
52- curl --output /dev/null -X DELETE http://localhost:8083/connectors/mongo-sink
53- curl --output /dev/null -X DELETE http://localhost:8083/connectors/mongo-source
54- docker-compose exec mongo1 /usr/bin/mongo --eval " db.dropDatabase()"
55- docker-compose down
56- echo -e " Bye!\n"
57- }
58- trap finish EXIT
59-
6075echo -e " \nKafka Topics:"
6176curl -X GET " http://localhost:8082/topics" -w " \n"
6277
0 commit comments