diff options
| author | Christian Cleberg <[email protected]> | 2026-04-08 14:29:21 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-08 14:29:21 -0500 |
| commit | a7c25076d16bde9ec928b9ef01bce952406ea7b1 (patch) | |
| tree | 802c5f84902f240c6aab95acc1e6348dfbd806c2 /app/main.py | |
| download | hutch-notify-a7c25076d16bde9ec928b9ef01bce952406ea7b1.tar.gz hutch-notify-a7c25076d16bde9ec928b9ef01bce952406ea7b1.tar.bz2 hutch-notify-a7c25076d16bde9ec928b9ef01bce952406ea7b1.zip | |
initial commit
Diffstat (limited to 'app/main.py')
| -rw-r--r-- | app/main.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..495e41f --- /dev/null +++ b/app/main.py @@ -0,0 +1,30 @@ +from contextlib import asynccontextmanager + +from fastapi import FastAPI +from sqlalchemy import text + +from app.db import engine, Base +from app.jobs import start_scheduler, scheduler +from app.routers.health import router as health_router +from app.routers.devices import router as devices_router +from app.routers.subscriptions import router as subscriptions_router +from app.routers.test import router as test_router + + +@asynccontextmanager +async def lifespan(app: FastAPI): + async with engine.begin() as conn: + await conn.run_sync(Base.metadata.create_all) + await conn.execute(text("select 1")) + start_scheduler() + yield + if scheduler.running: + scheduler.shutdown(wait=False) + await engine.dispose() + + +app = FastAPI(title="hutch-notify", lifespan=lifespan) +app.include_router(health_router) +app.include_router(devices_router) +app.include_router(subscriptions_router) +app.include_router(test_router) |
