fix(ops): harden deploy/restore/verify scripts
Some checks failed
Some checks failed
- 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:
@@ -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..."
|
||||
|
||||
Reference in New Issue
Block a user