-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathquick_setup_docker.sh
More file actions
executable file
·82 lines (75 loc) · 2.79 KB
/
quick_setup_docker.sh
File metadata and controls
executable file
·82 lines (75 loc) · 2.79 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
#!/usr/bin/env bash
# start_and_wait.sh - start docker compose and wait until CoexistAI app reports ready
# Usage: ./start_and_wait.sh
#!/usr/bin/env bash
# start_and_wait.sh - start docker compose and wait until CoexistAI app reports ready
# Usage: ./start_and_wait.sh
set -euo pipefail
if docker image inspect coexistai-app > /dev/null 2>&1; then
COMPOSE_CMD="docker compose up -d"
else
COMPOSE_CMD="docker compose up -d --build"
fi
TIMEOUT=${1:-500} # seconds to wait (default 500s)
INTERVAL=3
echo "Running: $COMPOSE_CMD"
$COMPOSE_CMD
echo ""
echo "Started containers (detached). Streaming logs from app container..."
echo "==============================================================================="
# Start streaming logs in the background and to stdout
docker compose logs -f app 2>&1 &
LOGS_PID=$!
# Give logs a moment to start
sleep 0.5
echo "Waiting for CoexistAI to report ready on http://localhost:8000/status (timeout ${TIMEOUT}s)..."
echo ""
START=$(date +%s)
while true; do
if [ $(( $(date +%s) - START )) -ge $TIMEOUT ]; then
kill $LOGS_PID 2>/dev/null || true
wait $LOGS_PID 2>/dev/null || true
echo ""
echo "==============================================================================="
echo "ERROR: Timed out waiting for app to become ready after ${TIMEOUT}s"
echo "Check full logs with: docker compose logs app --tail=500"
exit 2
fi
# fetch status JSON and extract status field using python for reliable parsing
status=$(curl -s http://localhost:8000/status || true)
if [ -n "$status" ]; then
st=$(printf '%s' "$status" | python3 -c 'import sys,json
try:
o=json.load(sys.stdin)
print(o.get("status",""))
except Exception:
print("")')
if [ "$st" = "ready" ]; then
kill $LOGS_PID 2>/dev/null || true
wait $LOGS_PID 2>/dev/null || true
echo ""
echo "==============================================================================="
echo "✓ CoexistAI status: READY"
echo "==============================================================================="
break
fi
if [ "$st" = "error" ]; then
kill $LOGS_PID 2>/dev/null || true
wait $LOGS_PID 2>/dev/null || true
echo ""
echo "==============================================================================="
echo "ERROR: CoexistAI reported error state"
echo "Check logs with: docker compose logs app --tail=200"
echo "==============================================================================="
exit 3
fi
fi
sleep $INTERVAL
done
echo ""
echo "Done: app is ready."
echo "Access the admin panel to configure models:"
echo " http://localhost:8000/admin"
echo "Default ADMIN_TOKEN is 123456 (changeable in .env)"
echo "==============================================================================="
exit 0