feat(api): DB off degraded 기동(store 폴백) + dev 인증 우회 — 풀 API 라이브 E2E 통과

- main lifespan: init_pool 실패해도 store 인메모리 폴백으로 degraded 기동
- deps: environment=dev면 쿠키 없어도 더미 학습자(로컬 라이브). prod는 401 유지
- 실증: POST /sessions(201) → turn → 서연 client_reply, safety_flagged=false
This commit is contained in:
Yun Chan 2026-06-25 23:51:59 +09:00
parent eca1f6a413
commit c57c34ade6
2 changed files with 21 additions and 7 deletions

View file

@ -25,14 +25,26 @@ from .routes import voice as voice_routes
@asynccontextmanager
async def lifespan(app: FastAPI):
"""startup: DB 풀 + 엔진 클라이언트 / shutdown: 정리."""
await init_pool()
"""startup: DB 풀 + 엔진 클라이언트 / shutdown: 정리.
DB 미가용(Docker off / NAS 연결불가)이면 store 인메모리 폴백으로 degraded 기동한다.
"""
try:
await init_pool()
except Exception as exc: # DB 없어도 store 폴백으로 1턴 동작 (dev/로컬)
import logging
logging.getLogger("uvicorn.error").warning(
"DB 풀 초기화 실패 — store 인메모리 폴백으로 degraded 기동: %s", exc
)
await engine_client.startup()
try:
yield
finally:
await engine_client.shutdown()
await close_pool()
try:
await close_pool()
except Exception:
pass
app = FastAPI(