49 lines
1.3 KiB
Bash
Executable File
49 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
ROOT="$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)"
|
|
COMPOSE_FILE="$ROOT/docker-compose.yml"
|
|
|
|
cd "$ROOT"
|
|
"$ROOT/scripts/render_cliproxy_config.sh"
|
|
|
|
OWNER="$(docker inspect storyforge-cliproxyapi --format '{{ index .Config.Labels "com.docker.compose.project.working_dir" }}' 2>/dev/null || true)"
|
|
if [ -n "$OWNER" ] && [ "$OWNER" != "$ROOT" ]; then
|
|
docker rm -f storyforge-cliproxyapi >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
docker compose -f "$COMPOSE_FILE" up -d --build collector n8n cli-proxy-api
|
|
|
|
python3 - <<'PY'
|
|
import time
|
|
import urllib.request
|
|
|
|
checks = [
|
|
("collector", "http://127.0.0.1:8081/healthz"),
|
|
("n8n", "http://127.0.0.1:5670/healthz"),
|
|
("cli-proxy-api", "http://127.0.0.1:8317/v1/models"),
|
|
]
|
|
|
|
deadline = time.time() + 45
|
|
pending = dict(checks)
|
|
while pending and time.time() < deadline:
|
|
for name, url in list(pending.items()):
|
|
try:
|
|
with urllib.request.urlopen(url, timeout=5) as resp:
|
|
print(f"{name} ready: {resp.status}")
|
|
pending.pop(name, None)
|
|
except Exception:
|
|
pass
|
|
if pending:
|
|
time.sleep(1)
|
|
|
|
if pending:
|
|
print("startup timeout:", ", ".join(pending))
|
|
raise SystemExit(1)
|
|
PY
|
|
|
|
echo "business started"
|
|
echo "collector: http://127.0.0.1:8081/healthz"
|
|
echo "n8n: http://127.0.0.1:5670/healthz"
|
|
echo "cli-proxy-api: http://127.0.0.1:8317/v1/models"
|