forked from Vasco0x4/AIDA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestart.sh
More file actions
executable file
·83 lines (68 loc) · 2.46 KB
/
Copy pathrestart.sh
File metadata and controls
executable file
·83 lines (68 loc) · 2.46 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
#!/usr/bin/env bash
# ==============================================================================
# AIDA - Restart Services
# ==============================================================================
# Restarts all containers and waits for them to be healthy.
# ==============================================================================
set -euo pipefail
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log() { echo -e "${GREEN}[✓]${NC} $*"; }
warn() { echo -e "${YELLOW}[!]${NC} $*"; }
error() { echo -e "${RED}[✗]${NC} $*"; }
section() { echo -e "\n${BLUE}══════════════════════════════════════${NC}\n${BLUE} $*${NC}\n${BLUE}══════════════════════════════════════${NC}"; }
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
section "AIDA - Restarting Services"
# Check if containers exist at all
RUNNING=$(docker compose ps --status running -q 2>/dev/null | wc -l | tr -d ' ')
STOPPED=$(docker compose ps --status exited -q 2>/dev/null | wc -l | tr -d ' ')
TOTAL=$((RUNNING + STOPPED))
if [[ "$TOTAL" -eq 0 ]]; then
warn "No AIDA containers found"
echo ""
echo "Use ./start.sh to start AIDA for the first time"
exit 1
fi
# Restart folder opener
pkill -f "folder_opener.py" 2>/dev/null || true
if [[ -f "$SCRIPT_DIR/tools/folder_opener.py" ]]; then
python3 "$SCRIPT_DIR/tools/folder_opener.py" &>/dev/null &
log "Restarted Folder Opener"
fi
# Restart containers
log "Restarting containers..."
docker compose restart
# Wait for services
section "Waiting for Services"
wait_for_service() {
local name=$1
local check_cmd=$2
local max_wait=${3:-30}
local i=0
printf " %-12s " "$name..."
while ! eval "$check_cmd" &>/dev/null; do
((i++))
if [[ $i -ge $max_wait ]]; then
echo -e "${RED}TIMEOUT${NC}"
return 1
fi
sleep 1
done
echo -e "${GREEN}Ready${NC}"
}
wait_for_service "PostgreSQL" "docker compose exec -T postgres pg_isready -U aida"
wait_for_service "Backend" "curl -sf http://localhost:8000/health"
wait_for_service "Frontend" "curl -sf http://localhost:5173"
# Success
section "AIDA Restarted"
echo ""
docker compose ps --format "table {{.Name}}\t{{.Status}}"
echo ""
log "Frontend: http://localhost:5173"
log "Backend: http://localhost:8000"
echo ""