Skip to content

Commit

Permalink
run a no-scan on startup to update hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
gantoine committed May 29, 2024
1 parent 4d0afbb commit c0fb04f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions backend/handler/scan_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ScanType(Enum):
UNIDENTIFIED = "unidentified"
PARTIAL = "partial"
COMPLETE = "complete"
NO_SCAN = "no_scan"


def _get_main_platform_igdb_id(platform: Platform):
Expand Down
17 changes: 15 additions & 2 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

import alembic.config
import uvicorn
from config import DEV_HOST, DEV_PORT, ROMM_AUTH_SECRET_KEY, DISABLE_CSRF_PROTECTION
from config import (
DEV_HOST,
DEV_PORT,
ROMM_AUTH_SECRET_KEY,
DISABLE_CSRF_PROTECTION,
SCAN_TIMEOUT,
)
from contextlib import asynccontextmanager
from endpoints import (
auth,
Expand All @@ -22,7 +28,7 @@
feeds,
firmware,
)
import endpoints.sockets.scan # noqa
from endpoints.sockets.scan import scan_platforms
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi_pagination import add_pagination
Expand All @@ -32,6 +38,8 @@
from handler.auth.base_handler import ALGORITHM
from handler.auth.hybrid_auth import HybridAuthBackend
from handler.auth.middleware import CustomCSRFMiddleware, SessionMiddleware
from handler.redis_handler import high_prio_queue
from handler.scan_handler import ScanType
from starlette.middleware.authentication import AuthenticationMiddleware
from utils import get_version

Expand Down Expand Up @@ -103,5 +111,10 @@ async def lifespan(app: FastAPI):
# Run migrations
alembic.config.main(argv=["upgrade", "head"])

# Run a no-scan in the background on startup
high_prio_queue.enqueue(
scan_platforms, [], ScanType.NO_SCAN, [], [], job_timeout=SCAN_TIMEOUT
)

# Run application
uvicorn.run("main:app", host=DEV_HOST, port=DEV_PORT, reload=True)

0 comments on commit c0fb04f

Please sign in to comment.