-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspark_docker_1_host.sh
executable file
·53 lines (48 loc) · 1.51 KB
/
spark_docker_1_host.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
cd mac
echo "==============================="
echo "Initializing Terraform..."
echo "==============================="
echo
terraform init
echo "==============================="
echo "Applying Terraform configuration..."
echo "==============================="
echo
terraform apply -auto-approve
echo "==============================="
echo "Project started."
echo "Waiting for 'wordcount-container' to start..."
echo "==============================="
echo
while ! docker ps --format '{{.Names}}' | grep -q '^wordcount-container$'; do
sleep 2
done
echo "==============================="
echo "Streaming logs from 'wordcount-container' (around 30 seconds)"
echo "==============================="
echo
docker logs -f wordcount-container & # Afficher les logs en direct en arrière-plan
LOGS_PID=$! # Récupérer l'ID du processus des logs
# Attendre que le conteneur s'arrête
while docker ps --format '{{.Names}}' | grep -q '^wordcount-container$'; do
sleep 2
done
# Arrêter le streaming des logs
kill $LOGS_PID 2>/dev/null
echo
echo "==============================="
echo "Wordcount process completed."
echo "You can check the logs!"
echo "==============================="
echo
read -p "Do you want to clear the project? (y/n) " choice
if [ "$choice" = "y" ]; then
terraform destroy -auto-approve
echo "==============================="
echo "Project cleared."
echo "==============================="
else
echo "==============================="
echo "Project kept."
echo "==============================="
fi