fix db error
This commit is contained in:
parent
698d0ca3f7
commit
b0055e174f
|
|
@ -32,6 +32,22 @@ def _init_seed_via_db() -> bytes:
|
|||
engine = create_engine(DATABASE_URL, pool_pre_ping=True)
|
||||
role = os.getenv("NODE_ROLE", "worker").lower()
|
||||
|
||||
# Best-effort: ensure service_config table exists before waiting on it.
|
||||
# This complements the synchronous init in app.__main__ and protects
|
||||
# against ordering issues where _secrets is imported before that init runs.
|
||||
try:
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
with engine.begin() as conn:
|
||||
inspector = inspect(conn)
|
||||
if not inspector.has_table('service_config'):
|
||||
ServiceConfigValue.__table__.create(bind=conn, checkfirst=True)
|
||||
except SQLAlchemyError as exc:
|
||||
make_log("HotWallet", f"Failed to ensure service_config table: {exc}", level="error")
|
||||
except Exception:
|
||||
# Avoid failing hard here; the fallback waiter below may still succeed
|
||||
pass
|
||||
|
||||
def db_ready(conn) -> bool:
|
||||
try:
|
||||
inspector = inspect(conn)
|
||||
|
|
|
|||
Loading…
Reference in New Issue