27 lines
582 B
Python
27 lines
582 B
Python
import asyncio
|
|
from fastapi import FastAPI
|
|
|
|
from app.api.routes import router as api_router
|
|
from app.core.config import get_settings
|
|
from app.core.logging import setup_logging
|
|
from app.services.runtime import scheduler, worker
|
|
|
|
settings = get_settings()
|
|
|
|
setup_logging()
|
|
|
|
app = FastAPI(title=settings.app_name)
|
|
app.include_router(api_router, prefix=settings.api_prefix)
|
|
|
|
|
|
@app.on_event("startup")
|
|
async def _startup() -> None:
|
|
scheduler.start()
|
|
await worker.start()
|
|
|
|
|
|
@app.on_event("shutdown")
|
|
async def _shutdown() -> None:
|
|
scheduler.shutdown()
|
|
await worker.stop()
|