From a17ba1e8d8765d54ddcf1b514a5d6e44aa183b41 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sun, 15 Mar 2026 04:57:49 -0700 Subject: [PATCH] feat(app): use reset_running_tasks() on startup to preserve queued tasks --- app/app.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/app.py b/app/app.py index b1bf71a..fcd04df 100644 --- a/app/app.py +++ b/app/app.py @@ -42,12 +42,12 @@ def _startup() -> None: 2. Auto-queues re-runs for any research generated without SearXNG data, if SearXNG is now reachable. """ + # Reset only in-flight tasks — queued tasks survive for the scheduler to resume. + # MUST run before any submit_task() call in this function. + from scripts.db import reset_running_tasks + reset_running_tasks(get_db_path()) + conn = sqlite3.connect(get_db_path()) - conn.execute( - "UPDATE background_tasks SET status='failed', error='Interrupted by server restart'," - " finished_at=datetime('now') WHERE status IN ('queued','running')" - ) - conn.commit() # Auto-recovery: re-run LLM-only research when SearXNG is available try: