feat: real worker status, covers on Recently Pressed, library counter

- Worker stamps a throttled worker.heartbeat; GET /api/worker reports online
  from its updatedAt recency (DB-time); masthead shows a live listening/offline
  dot instead of a static decoration.
- /api/requests enriched with rgMbid; Recently Pressed shows cover thumbs.
- Library album count moved from the filter row into a section header.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan
2026-07-12 17:58:23 +02:00
parent e624d12089
commit 606ea82b70
10 changed files with 103 additions and 15 deletions
+5
View File
@@ -16,6 +16,7 @@ from lyra_worker.registry import (
from lyra_worker.scan import scan_chunk
IDLE_SLEEP = 2.0
HEARTBEAT_SECONDS = 15.0 # how often to stamp worker.heartbeat (its updatedAt = liveness)
MONITOR_TICK_SECONDS = 60.0
DISCOVER_TICK_SECONDS = 300.0 # check the discovery interval every 5 min (interval itself is hours)
DEST_ROOT = "/music" # must match run_pipeline's default library root
@@ -147,6 +148,7 @@ def run_forever() -> None:
print("worker: waiting for jobs", flush=True)
last_tick = 0.0
last_discover_tick = 0.0
last_heartbeat = 0.0
try:
while True:
# A transient DB connection loss (e.g. AdminShutdown when Postgres restarts) raises
@@ -157,6 +159,9 @@ def run_forever() -> None:
config = get_config(conn)
mcfg = MonitorConfig.from_config(config)
now = time.monotonic()
if now - last_heartbeat >= HEARTBEAT_SECONDS:
_set_config(conn, "worker.heartbeat", "1") # value irrelevant; updatedAt is the signal
last_heartbeat = now
if mcfg.enabled and now - last_tick >= MONITOR_TICK_SECONDS:
try:
sweep(conn, browser, mcfg)