From c1593fe55bc0f50690b5f4bf9e0113bb1dfbad17 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 18 May 2026 02:10:45 -0700 Subject: [PATCH] Report supervisord runner in live progress --- Dockerfile | 3 +++ archivebox/core/views.py | 15 +++++++++++++-- archivebox/tests/test_admin_views.py | 20 ++++++++++++++++++++ pyproject.toml | 4 ---- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2bcc2f8b..a738975f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,6 +53,8 @@ ARG TARGETPLATFORM ARG TARGETOS ARG TARGETARCH ARG TARGETVARIANT +ARG ABX_PLUGINS_REF=f576a7c81a17b0e49adf4789ac7f7143ece1282f +ARG ABX_DL_REF=3cddb1bf4d8a37c49f2a70810e0da840acc96c17 ######### Environment Variables ################################# # Global build-time and runtime environment constants + default pkg manager config @@ -337,6 +339,7 @@ RUN --mount=type=bind,source=pyproject.toml,target=/app/pyproject.toml \ echo "[+] PIP Installing ArchiveBox dependencies from pyproject.toml..." \ && apt-get update -qq \ && apt-get install -qq -y --no-install-recommends build-essential gcc python3-dev \ + && printf '\n[tool.uv.sources]\n"abx-plugins" = { git = "https://github.com/ArchiveBox/abx-plugins.git", rev = "%s" }\n"abx-dl" = { git = "https://github.com/ArchiveBox/abx-dl.git", rev = "%s" }\n' "$ABX_PLUGINS_REF" "$ABX_DL_REF" >> pyproject.toml \ && uv sync \ --inexact \ --all-extras \ diff --git a/archivebox/core/views.py b/archivebox/core/views.py index 09ce0f66..1bb2d323 100644 --- a/archivebox/core/views.py +++ b/archivebox/core/views.py @@ -1307,8 +1307,19 @@ def live_progress_view(request): .order_by("-started_at") .first() ) - orchestrator_running = orchestrator_proc is not None - orchestrator_pid = orchestrator_proc.pid if orchestrator_proc else None + runner_worker = None + try: + from archivebox.workers.supervisord_util import get_existing_supervisord_process, get_worker + + supervisor = get_existing_supervisord_process() + runner_worker = get_worker(supervisor, "worker_runner") if supervisor else None + except Exception: + runner_worker = None + + runner_worker_running = bool(runner_worker and runner_worker.get("statename") in ("STARTING", "RUNNING")) + runner_worker_pid = runner_worker.get("pid") if runner_worker else None + orchestrator_running = orchestrator_proc is not None or runner_worker_running + orchestrator_pid = orchestrator_proc.pid if orchestrator_proc else runner_worker_pid # Get model counts by status crawls_pending = Crawl.objects.filter(status=Crawl.StatusChoices.QUEUED).count() crawls_started = Crawl.objects.filter(status=Crawl.StatusChoices.STARTED).count() diff --git a/archivebox/tests/test_admin_views.py b/archivebox/tests/test_admin_views.py index d31d834d..6145e4ca 100644 --- a/archivebox/tests/test_admin_views.py +++ b/archivebox/tests/test_admin_views.py @@ -1236,6 +1236,26 @@ class TestArchiveResultAdminListView: class TestLiveProgressView: + def test_live_progress_reports_supervisord_runner_running(self, client, admin_user, db, monkeypatch): + import archivebox.machine.models as machine_models + import archivebox.workers.supervisord_util as supervisord_util + + machine_models._CURRENT_MACHINE = None + monkeypatch.setattr(supervisord_util, "get_existing_supervisord_process", lambda: object()) + monkeypatch.setattr( + supervisord_util, + "get_worker", + lambda supervisor, name: {"statename": "RUNNING", "pid": 12345} if name == "worker_runner" else None, + ) + + client.login(username="testadmin", password="testpassword") + response = client.get(reverse("live_progress"), HTTP_HOST=ADMIN_HOST) + + assert response.status_code == 200 + payload = response.json() + assert payload["orchestrator_running"] is True + assert payload["orchestrator_pid"] == 12345 + def test_live_progress_ignores_unscoped_running_processes_when_no_crawls(self, client, admin_user, db): import os import archivebox.machine.models as machine_models diff --git a/pyproject.toml b/pyproject.toml index bc0aa865..c58886d6 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -158,10 +158,6 @@ exclude-newer = "5 days" exclude-newer-package = { abx-plugins = "1 second", abx-dl = "1 second", abxpkg = "1 second", abxbus = "1 second" } # compile-bytecode = true -[tool.uv.sources] -"abx-plugins" = { git = "https://github.com/ArchiveBox/abx-plugins.git", rev = "f576a7c81a17b0e49adf4789ac7f7143ece1282f" } -"abx-dl" = { git = "https://github.com/ArchiveBox/abx-dl.git", rev = "3cddb1bf4d8a37c49f2a70810e0da840acc96c17" } - [build-system] requires = ["pdm-backend"] build-backend = "pdm.backend"