feat(contract): add opt-in MAX configuration and lifecycle
CI / ruff · pytest (pull_request) Successful in 2m6s
CI / ruff · pytest (pull_request) Successful in 2m6s
Refs #81
This commit is contained in:
+18
-6
@@ -30,13 +30,25 @@ async def lifespan(_: FastAPI) -> AsyncGenerator[None, None]:
|
||||
# In compose Postgres is required and healthy before the app starts; this branch is for running the
|
||||
# API (and its tests) without a database. Endpoints touching the DB will fail until it is reachable.
|
||||
log.error("db init failed, continuing without db: %s", type(exc).__name__)
|
||||
if settings.max_enabled:
|
||||
raise # MAX requires persistent bindings and a delivery queue.
|
||||
# Lanes fill these in (#13, #11); main.py itself stays frozen (#34).
|
||||
await scheduler.start()
|
||||
await telegram.start()
|
||||
yield
|
||||
await telegram.stop()
|
||||
await scheduler.stop()
|
||||
await dispose()
|
||||
max_channel = None
|
||||
try:
|
||||
await telegram.start()
|
||||
if settings.max_enabled:
|
||||
from app.channels import max_bot
|
||||
|
||||
max_channel = max_bot
|
||||
await max_channel.start()
|
||||
await scheduler.start()
|
||||
yield
|
||||
finally:
|
||||
await scheduler.stop()
|
||||
if max_channel is not None:
|
||||
await max_channel.stop()
|
||||
await telegram.stop()
|
||||
await dispose()
|
||||
|
||||
|
||||
app = FastAPI(title="PTSRaiAgent API", version="0.1.0", lifespan=lifespan)
|
||||
|
||||
Reference in New Issue
Block a user