fix(ops): harden deploy/restore/verify scripts
Some checks failed
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / ruff (push) Successful in 9s
CI / pytest (push) Has been cancelled

- deploy.sh: add DB health wait before migrations, prune old Docker images
- restore.sh: add redis-exporter to stop list, replace sleep with DB health wait
- verify-server.sh: add redis-exporter to expected containers, add Sentry + Redis exporter checks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 00:23:14 +01:00
parent 35d1559162
commit 93a2d9baff
3 changed files with 85 additions and 15 deletions

View File

@@ -46,10 +46,10 @@ restore_orion() {
log "=== Restoring Orion database ==="
# Stop app containers (keep DB running)
# Stop app containers (keep DB and Redis running)
log "Stopping Orion app containers..."
cd "${ORION_APP_DIR}"
docker compose --profile full stop api celery-worker celery-beat flower 2>/dev/null || true
docker compose --profile full stop api celery-worker celery-beat flower redis-exporter 2>/dev/null || true
# Drop and recreate database
log "Dropping and recreating ${db_name}..."
@@ -66,8 +66,19 @@ restore_orion() {
log "Running Alembic migrations..."
docker compose --profile full start api 2>/dev/null || \
docker compose --profile full up -d api
sleep 5 # Wait for API container to be ready
docker compose --profile full exec -e PYTHONPATH=/app api python -m alembic upgrade heads
# Wait for API container to be healthy before running migrations
log "Waiting for API container to be ready..."
for i in $(seq 1 12); do
if docker compose --profile full exec -T db pg_isready -U orion_user -d orion_db > /dev/null 2>&1; then
log "Database is ready (attempt $i/12)"
break
fi
[ "$i" -eq 12 ] && { log "WARNING: database may not be ready, attempting migration anyway"; }
sleep 5
done
docker compose --profile full exec -T -e PYTHONPATH=/app api python -m alembic upgrade heads
# Restart all
log "Restarting all services..."