Spaces:
Sleeping
Sleeping
David Prince commited on
Commit ·
f39c5f0
1
Parent(s): 9b613a9
fix: log real PostgreSQL startup error instead of silently falling back
Browse files- app_part1.py +5 -0
app_part1.py
CHANGED
|
@@ -88,7 +88,12 @@ async def init_db_pool() -> asyncpg.Pool:
|
|
| 88 |
async def lifespan(app: FastAPI):
|
| 89 |
global db_pool
|
| 90 |
try:
|
|
|
|
| 91 |
db_pool = await init_db_pool()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
logger.info("Database pool initialized.")
|
| 93 |
except Exception as exc:
|
| 94 |
logger.error("Failed to initialize Postgres pool. Falling back to memory: %s", exc)
|
|
|
|
| 88 |
async def lifespan(app: FastAPI):
|
| 89 |
global db_pool
|
| 90 |
try:
|
| 91 |
+
try:
|
| 92 |
db_pool = await init_db_pool()
|
| 93 |
+
logger.info("Database pool initialized successfully.")
|
| 94 |
+
except Exception as db_err:
|
| 95 |
+
logger.error(f"Database pool FAILED: {db_err}")
|
| 96 |
+
db_pool = None
|
| 97 |
logger.info("Database pool initialized.")
|
| 98 |
except Exception as exc:
|
| 99 |
logger.error("Failed to initialize Postgres pool. Falling back to memory: %s", exc)
|