mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-14 11:06:13 +05:00
Report supervisord runner in live progress
This commit is contained in:
parent
bfdf293585
commit
c1593fe55b
@ -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 \
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user