-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-all.sh
More file actions
88 lines (69 loc) · 2.57 KB
/
Copy pathstart-all.sh
File metadata and controls
88 lines (69 loc) · 2.57 KB
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
#!/bin/bash
#mvn clean package -f eureka-service/
#mvn clean package -f auth-service/
#mvn clean package -f product-service/
#mvn clean package -f order-service/
#mvn clean package -f gateway-service/
#java -jar eureka-service/target/eureka-service-0.0.1-SNAPSHOT.jar &
#java -jar eureka-service/target/eureka-service-0.0.1-SNAPSHOT.jar > logs/eureka.log 2>&1 &
#java -jar auth-service/target/auth-service-0.0.1-SNAPSHOT.jar &
#java -jar product-service/target/product-service-0.0.1-SNAPSHOT.jar &
#java -jar order-service/target/order-service-0.0.1-SNAPSHOT.jar &
#java -jar gateway-service/target/gateway-service-0.0.1-SNAPSHOT.jar &
#!/bin/bash
# Função para aguardar até que o Eureka esteja no ar
wait_for_service() {
local url=$1
local retries=10
local count=0
echo "Aguardando o serviço em $url..."
while ! curl -s "$url" > /dev/null; do
count=$((count + 1))
if [ $count -ge $retries ]; then
echo "Falhou ao conectar ao serviço $url após $retries tentativas."
exit 1
fi
echo "Tentativa $count de $retries: O serviço não está disponível ainda... aguardando."
sleep 5
done
echo "Serviço $url está disponível!"
}
# Fazer o build e iniciar os serviços
echo "Iniciando o Eureka..."
mvn clean package -f eureka-service/
if [ $? -ne 0 ]; then
echo "Erro durante o build do Eureka. Abortando..."
exit 1
fi
java -jar eureka-service/target/eureka-service-0.0.1-SNAPSHOT.jar &
# Aguardar o Eureka ficar no ar antes de iniciar os outros serviços
wait_for_service "http://localhost:8761/eureka"
echo "Iniciando o Auth Service..."
mvn clean package -f auth-service/
if [ $? -ne 0 ]; then
echo "Erro durante o build do Auth Service. Abortando..."
exit 1
fi
java -jar auth-service/target/auth-service-0.0.1-SNAPSHOT.jar &
echo "Iniciando o Product Service..."
mvn clean package -f product-service/
if [ $? -ne 0 ]; then
echo "Erro durante o build do Product Service. Abortando..."
exit 1
fi
java -jar product-service/target/product-service-0.0.1-SNAPSHOT.jar &
echo "Iniciando o Order Service..."
mvn clean package -f order-service/
if [ $? -ne 0 ]; then
echo "Erro durante o build do Order Service. Abortando..."
exit 1
fi
java -jar order-service/target/order-service-0.0.1-SNAPSHOT.jar &
echo "Iniciando o Gateway Service..."
mvn clean package -f gateway-service/
if [ $? -ne 0 ]; then
echo "Erro durante o build do Gateway Service. Abortando..."
exit 1
fi
java -jar gateway-service/target/gateway-service-0.0.1-SNAPSHOT.jar &
echo "Todos os serviços foram iniciados!"