-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
89 lines (80 loc) · 1.98 KB
/
deploy.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
86
87
88
89
#!/bin/sh
set -e
echo " "
echo "Please be sure that env variable JAVA_HOME is set, in order to point to the JDK path"
echo " "
echo " "
if [ -z ${JAVA_HOME+x} ]; then echo "JAVA_HOME is unset"; else echo "JAVA_HOME is set to '$JAVA_HOME'"; fi
echo " "
echo " "
echo "starting gradle tasks..."
echo " "
echo " "
echo "Eureka server"
./gradlew ":Eureka:bootJar"
echo " "
echo "Catalog Service"
./gradlew ":CatalogService:bootJar"
echo " "
echo "Order Service"
./gradlew ":OrderService:bootJar"
echo " "
echo "Wallet Service"
./gradlew ":WalletService:bootJar"
echo " "
echo "Warehouse Service"
./gradlew ":WarehouseService:bootJar"
echo " "
echo " "
echo "Starting docker-compose..."
echo " "
echo " "
docker-compose "down"
docker-compose "build"
docker-compose "up" "-d"
docker "image" "prune" "-f"
docker "volume" "prune" "-f"
echo "Waiting 5 seconds to be sure every container is ready..."
sleep 5
DEBEZIUM_CONFIG_FILE=./debezium_config.json
DEBEZIUM_CONFIG="$(cat "$DEBEZIUM_CONFIG_FILE" | tr -d '\r' | tr -d '\n' | tr -d ' ' )"
echo $DEBEZIUM_CONFIG
echo " "
until output=$(docker exec kafka-connect curl -f kafka-connect:8083/connectors)
do
echo "Service is unavailable, sleeping..."
sleep 5
done
sleep 2
output=$(echo $output | tr -d '[' | tr -d ']' | tr -d '"')
echo "$output"
IFS=',' read -a output <<< "$output"
echo " "
echo "Deleting existing connectors..."
echo " "
for connector in ${output[@]}
do
until docker exec kafka-connect curl -i -f -X DELETE kafka-connect:8083/connectors/"$connector"
do
echo "Route is unavailable, sleeping..."
sleep 5
done
done
sleep 2
echo " "
echo "Configuring the connector..."
echo " "
until out=$(docker exec kafka-connect curl --fail -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" kafka-connect:8083/connectors/ -d "$DEBEZIUM_CONFIG")
do
echo " "
echo "Route is unavailable, sleeping..."
echo " "
sleep 5
done
echo " "
echo "$out"
sleep 2
echo " "
echo " "
echo " "
echo "Finished."