Fix: Defer database connection to allow container startup
Browse files- src/main.py +5 -7
src/main.py
CHANGED
|
@@ -23,14 +23,12 @@ async def lifespan(app: FastAPI):
|
|
| 23 |
Manage application lifespan events.
|
| 24 |
|
| 25 |
Handles database connection on startup and graceful shutdown.
|
|
|
|
| 26 |
"""
|
| 27 |
-
# Startup:
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
except Exception as e:
|
| 32 |
-
print(f"[ERROR] Database initialization failed: {e}")
|
| 33 |
-
raise
|
| 34 |
|
| 35 |
yield
|
| 36 |
|
|
|
|
| 23 |
Manage application lifespan events.
|
| 24 |
|
| 25 |
Handles database connection on startup and graceful shutdown.
|
| 26 |
+
Database connection is deferred to first actual use.
|
| 27 |
"""
|
| 28 |
+
# Startup: Skip database initialization to allow container to start
|
| 29 |
+
# Database will connect on first request
|
| 30 |
+
print("[INFO] Starting application (database connection deferred)")
|
| 31 |
+
print("[INFO] Database will connect on first API request")
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
yield
|
| 34 |
|