Resolve fastapi deprecation warning
This commit is contained in:
parent
563f7b5a42
commit
bc534e923c
2 changed files with 17 additions and 13 deletions
|
|
@ -11,7 +11,7 @@ classifiers = [
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi2html",
|
"ansi2html",
|
||||||
"fastapi",
|
"fastapi>=0.93",
|
||||||
"gunicorn",
|
"gunicorn",
|
||||||
"httpx",
|
"httpx",
|
||||||
"jinja2",
|
"jinja2",
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,27 @@
|
||||||
|
from collections.abc import AsyncGenerator
|
||||||
|
from contextlib import asynccontextmanager
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|
||||||
from . import __version__, api, controller, k8s, webhooks, webui
|
from . import __version__, api, controller, k8s, webhooks, webui
|
||||||
|
|
||||||
|
|
||||||
|
@asynccontextmanager
|
||||||
|
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||||
|
await k8s.load_kube_config()
|
||||||
|
await controller.controller.start()
|
||||||
|
yield
|
||||||
|
await controller.controller.stop()
|
||||||
|
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="Runboat", description="Runbot on Kubernetes ☸️", version=__version__
|
title="Runboat",
|
||||||
|
description="Runbot on Kubernetes ☸️",
|
||||||
|
version=__version__,
|
||||||
|
lifespan=lifespan,
|
||||||
)
|
)
|
||||||
app.include_router(api.router, prefix="/api/v1", tags=["api"])
|
app.include_router(api.router, prefix="/api/v1", tags=["api"])
|
||||||
app.include_router(webhooks.router, tags=["webhooks"])
|
app.include_router(webhooks.router, tags=["webhooks"])
|
||||||
app.include_router(webui.router, tags=["webui"])
|
app.include_router(webui.router, tags=["webui"])
|
||||||
|
|
||||||
webui.mount(app)
|
webui.mount(app)
|
||||||
|
|
||||||
|
|
||||||
@app.on_event("startup")
|
|
||||||
async def startup() -> None:
|
|
||||||
await k8s.load_kube_config()
|
|
||||||
await controller.controller.start()
|
|
||||||
|
|
||||||
|
|
||||||
@app.on_event("shutdown")
|
|
||||||
async def shutdown() -> None:
|
|
||||||
await controller.controller.stop()
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue