85 lines
2.4 KiB
Bash
85 lines
2.4 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="${GROUPHOME_ROOT:-/mnt/DATA/git/comiaunicaty}"
|
|
PYTHON_PROBE="${PYTHON_PROBE:-python3}"
|
|
BACKEND_URL="${GROUPHOME_BACKEND_URL:-http://127.0.0.1:8000}"
|
|
FRONTEND_URL="${GROUPHOME_FRONTEND_URL:-http://127.0.0.1:5173}"
|
|
OPEN_BROWSER="${OPEN_BROWSER:-1}"
|
|
KEEP_RUNNING="${GROUPHOME_KEEP_RUNNING:-0}"
|
|
|
|
fail() {
|
|
printf 'launch-dev: %s\n' "$*" >&2
|
|
exit 1
|
|
}
|
|
|
|
wait_for_url() {
|
|
"$PYTHON_PROBE" - "$1" <<'PY'
|
|
import sys
|
|
import time
|
|
import urllib.request
|
|
|
|
url = sys.argv[1]
|
|
deadline = time.monotonic() + 180
|
|
last_error = None
|
|
while time.monotonic() < deadline:
|
|
try:
|
|
with urllib.request.urlopen(url, timeout=3) as response:
|
|
if 200 <= response.status < 500:
|
|
raise SystemExit(0)
|
|
except Exception as exc: # noqa: BLE001 - printed only on timeout.
|
|
last_error = exc
|
|
time.sleep(2)
|
|
print(f"Timed out waiting for {url}: {last_error}", file=sys.stderr)
|
|
raise SystemExit(1)
|
|
PY
|
|
}
|
|
|
|
cleanup() {
|
|
if [ "$KEEP_RUNNING" != "1" ]; then
|
|
(cd "$ROOT" && docker compose down) >/dev/null 2>&1 || true
|
|
fi
|
|
}
|
|
trap cleanup EXIT INT TERM
|
|
|
|
command -v docker >/dev/null 2>&1 || fail "docker not found. Install Docker with Compose support, then rerun this launcher."
|
|
command -v "$PYTHON_PROBE" >/dev/null 2>&1 || fail "$PYTHON_PROBE not found. Set PYTHON_PROBE to a Python executable."
|
|
[ -f "$ROOT/docker-compose.yml" ] || fail "docker-compose.yml not found at $ROOT"
|
|
|
|
printf 'Starting GroupHome with Docker Compose\n'
|
|
(
|
|
cd "$ROOT"
|
|
docker compose up --build -d
|
|
)
|
|
|
|
printf 'Waiting for %s/api/health\n' "$BACKEND_URL"
|
|
wait_for_url "$BACKEND_URL/api/health" || {
|
|
(cd "$ROOT" && docker compose logs --tail=120) >&2 || true
|
|
fail "backend did not become healthy"
|
|
}
|
|
|
|
printf 'Waiting for %s\n' "$FRONTEND_URL"
|
|
wait_for_url "$FRONTEND_URL" || {
|
|
(cd "$ROOT" && docker compose logs --tail=120) >&2 || true
|
|
fail "frontend did not become reachable"
|
|
}
|
|
|
|
if [ "$OPEN_BROWSER" = "1" ] && command -v xdg-open >/dev/null 2>&1; then
|
|
xdg-open "$FRONTEND_URL" >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
cat <<EOF
|
|
|
|
GroupHome is running through Docker Compose.
|
|
Web UI: $FRONTEND_URL
|
|
API: $BACKEND_URL/api
|
|
Health: $BACKEND_URL/api/health
|
|
Demo invite: $FRONTEND_URL/join/demo-fc-invite
|
|
|
|
Compose logs are attached below.
|
|
Press Ctrl+C to stop services. Set GROUPHOME_KEEP_RUNNING=1 to leave them running after this launcher exits.
|
|
EOF
|
|
|
|
cd "$ROOT"
|
|
docker compose logs -f
|