playreel/backend/main.py
2026-09-15 16:00:54 +09:00

33 lines
805 B
Python

from contextlib import asynccontextmanager
from fastapi import FastAPI
from pipelines import worker
from routers import archive, auth, f1, playreel
from utils import blob
from utils.database import close_engine, create_missing_tables
@asynccontextmanager
async def lifespan(app: FastAPI):
# 테이블 정의는 tables.task 를 임포트한 라우터·파이프라인이 이미 등록해 둔다
await create_missing_tables()
worker.start()
yield
await worker.stop()
await blob.close_client()
await close_engine()
app = FastAPI(title="poster-alive", lifespan=lifespan)
app.include_router(auth.router)
app.include_router(f1.router)
app.include_router(playreel.router)
app.include_router(archive.router)
@app.get("/api/health")
async def health():
return {"ok": True}