Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import tempfile
import threading
import uuid
from contextlib import asynccontextmanager
from datetime import datetime, timezone
from pathlib import Path
from typing import List
Expand Down Expand Up @@ -94,7 +95,17 @@
MAX_UPLOAD_SIZE = MAX_UPLOAD_MB * 1024 * 1024

logger = logging.getLogger(__name__)
app = FastAPI(title="PatchPilot API", version="0.1.0")


@asynccontextmanager
async def lifespan(app: FastAPI):
await init_db()
# Start background cleanup for finished ACTIVE_SCANS entries
asyncio.create_task(_cleanup_active_scans_loop())
yield


app = FastAPI(title="PatchPilot API", version="0.1.0", lifespan=lifespan)

ALLOWED_ORIGINS = [
"http://localhost:5173",
Expand Down Expand Up @@ -128,13 +139,6 @@
ensure_dir(WORK_ROOT)


@app.on_event("startup")
async def startup():
await init_db()
# Start background cleanup for finished ACTIVE_SCANS entries
asyncio.create_task(_cleanup_active_scans_loop())


@app.get("/health")
def health():
scanners = {
Expand Down
Loading