-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrun.sh
More file actions
49 lines (39 loc) · 1.31 KB
/
run.sh
File metadata and controls
49 lines (39 loc) · 1.31 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
#!/bin/bash
set -euo pipefail
trap 'echo -e "\033[0;31m❌ Error occurred. Exiting...\033[0m"; exit 1' ERR
# Constants
CONTAINERS=("Speak2Summary-flask" "Speak2Summary-celery" "Speak2Summary-redis")
COMPOSE_FILE="docker-compose.yml"
log() {
echo -e "\033[1;34m[INFO]\033[0m $*"
}
stop_and_remove_containers() {
log "Stopping and removing containers if they exist..."
for container in "${CONTAINERS[@]}"; do
if docker ps -a --format '{{.Names}}' | grep -qw "$container"; then
docker stop "$container" >/dev/null 2>&1 || true
docker rm "$container" >/dev/null 2>&1 || true
log "✅ Removed $container"
else
log "⏭️ Container $container does not exist. Skipping..."
fi
done
}
start_docker_compose() {
if [[ -f "$COMPOSE_FILE" ]]; then
docker compose up --build -d
else
echo -e "\033[0;31m❌ Compiled code or docker-compose.yml not found.\033[0m"
exit 1
fi
}
cleanup() {
log "Cleaning up compiled directory..."
rm -rf "$COMPILED_DIR"
}
# ------------------ MAIN ------------------
log "🚀 Starting Speak2Summary deployment..."
stop_and_remove_containers
start_docker_compose
# ping the :5000/health endpoint to ensure the service is up
log "🎉 Speak2Summary started and cleaned up successfully!"