This commit is contained in:
2026-05-04 13:13:01 +02:00
parent 48d57c31e1
commit d25b56e7e1
22 changed files with 99 additions and 161 deletions

View File

@@ -145,7 +145,8 @@ CREATE TABLE scheduler_lock (
pid INTEGER NOT NULL,
hostname TEXT NOT NULL,
created_at REAL NOT NULL,
heartbeat_at REAL NOT NULL
heartbeat_at REAL NOT NULL,
heartbeat_timeout REAL NOT NULL DEFAULT 300
);
""",
5: """
@@ -253,7 +254,6 @@ CREATE INDEX IF NOT EXISTS idx_import_log_source_id_desc
async def _configure_connection(db: aiosqlite.Connection) -> None:
"""Apply hardening pragmas to a newly-opened SQLite connection."""
await db.execute("PRAGMA journal_mode=WAL;")
await db.execute("PRAGMA foreign_keys=ON;")
await db.execute("PRAGMA busy_timeout=5000;")

View File

@@ -229,6 +229,11 @@ async def startup_shared_resources(
lambda: _stage_create_scheduler(),
)
# Store resources on app.state BEFORE registering tasks (tasks depend on them)
app.state.http_session = http_session
app.state.geo_cache = geo_cache
app.state.scheduler = scheduler
# Stage 6: Register tasks
await dag.execute_stage(
StartupStage.TASKS,
@@ -239,9 +244,6 @@ async def startup_shared_resources(
if not await dag.health_check():
raise RuntimeError("Startup health check failed")
# Store the geo_cache on app state for dependency injection
app.state.geo_cache = geo_cache
log.info(
"startup_completed_successfully",
stages=len(dag.context.completed_stages),
@@ -469,8 +471,6 @@ async def _stage_register_tasks(app: FastAPI, scheduler: AsyncIOScheduler) -> No
app: The FastAPI application instance.
scheduler: The APScheduler scheduler to register tasks with.
"""
# Set scheduler on app.state before registering tasks (they use app.state.scheduler)
app.state.scheduler = scheduler
scheduler_lock_heartbeat.register(app)
health_check.register(app)
await blocklist_import.register(app)