A10: Add Caddy config validation and scheduler checks to bootstrap

This commit is contained in:
ik
2026-09-11 07:35:22 +07:00
parent 641374ddbc
commit 2ba4f6027d
+21
View File
@@ -27,6 +27,27 @@ curl -fsS "http://127.0.0.1:$BOOTSTRAP_WEB_PORT/" >/dev/null
curl -fsS -D - -o /dev/null "http://127.0.0.1:$BOOTSTRAP_API_PORT/health" | grep -qi '^x-frame-options: DENY' curl -fsS -D - -o /dev/null "http://127.0.0.1:$BOOTSTRAP_API_PORT/health" | grep -qi '^x-frame-options: DENY'
curl -fsS -D - -o /dev/null "http://127.0.0.1:$BOOTSTRAP_API_PORT/health" | grep -qi '^cross-origin-opener-policy: same-origin' curl -fsS -D - -o /dev/null "http://127.0.0.1:$BOOTSTRAP_API_PORT/health" | grep -qi '^cross-origin-opener-policy: same-origin'
# A10: Validate Caddy configuration without running the proxy
echo "Validating Caddy configuration..."
docker compose --env-file .env.production.example -f compose.production.yaml -f deploy/compose.bootstrap.yaml run --rm --no-deps --entrypoint "caddy adapt --config /etc/caddy/Caddyfile --pretty" proxy >/dev/null 2>&1 || {
echo "ERROR: Caddy configuration is invalid" >&2
exit 1
}
echo "Caddy configuration valid ✓"
# A10: Check scheduler can start without external network
echo "Validating community scheduler..."
$compose up --build -d --wait community-scheduler
# Scheduler runs in a loop, check it's healthy by verifying the process is running
$compose exec -T community-scheduler python -c "from app.community_scheduler import schedule_interval; print('scheduler module loads OK')" >/dev/null 2>&1 || {
echo "ERROR: Community scheduler failed to start" >&2
$compose logs --no-color community-scheduler >&2
exit 1
}
echo "Community scheduler valid ✓"
# Stop scheduler to free resources
$compose stop community-scheduler
# A10: Extract Alembic revision ID programmatically, handle multiple heads # A10: Extract Alembic revision ID programmatically, handle multiple heads
ALEMBIC_HEADS_OUTPUT=$($compose exec -T api alembic heads 2>/dev/null || true) ALEMBIC_HEADS_OUTPUT=$($compose exec -T api alembic heads 2>/dev/null || true)
# Extract revision IDs (first field before space or '(head)'), handle multiple heads # Extract revision IDs (first field before space or '(head)'), handle multiple heads