From e2a473aa98843b6b358a69a49dbd8d08ec97f0b6 Mon Sep 17 00:00:00 2001 From: busya Date: Tue, 26 May 2026 20:15:32 +0300 Subject: [PATCH] fix: prevent set -e from killing entrypoint on DB detection The python3 DB detection script exits with code 1 (empty) or 2 (legacy), but entrypoint has set -e which kills the script on any non-zero exit. Fixed by using '|| _db_state=$?' pattern to safely capture exit code without triggering set -e. --- docker/backend.entrypoint.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docker/backend.entrypoint.sh b/docker/backend.entrypoint.sh index eab4441e..dc9b32b3 100755 --- a/docker/backend.entrypoint.sh +++ b/docker/backend.entrypoint.sh @@ -152,18 +152,19 @@ install_certificates install_playwright # Check DB state: empty, legacy (tables exist but no alembic), or managed +# || prevents set -e from killing the script on non-zero exit from detection script +_db_state=0 python3 -c " import os from sqlalchemy import create_engine, inspect e = create_engine(os.environ['DATABASE_URL']) insp = inspect(e) if 'alembic_version' in insp.get_table_names(): - exit(0) # managed → normal upgrade + exit(0) if not insp.get_table_names(): - exit(1) # empty → fresh upgrade -exit(2) # legacy → stamp head -" 2>/dev/null -_db_state=$? + exit(1) +exit(2) +" 2>&1 || _db_state=$? if [ $_db_state -eq 0 ]; then echo "[entrypoint] Running Alembic migrations (incremental)..."