feat: make version check periodic

This commit is contained in:
Alex
2026-04-25 14:57:37 +01:00
parent 9c8ae9d540
commit ef976eeb06
2 changed files with 25 additions and 5 deletions

View File

@@ -140,6 +140,11 @@ def setup_periodic_tasks(sender, **kwargs):
cleanup_pending_tool_state.s(),
name="cleanup-pending-tool-state",
)
sender.add_periodic_task(
timedelta(hours=7),
version_check_task.s(),
name="version-check",
)
@celery.task(bind=True)
@@ -176,3 +181,16 @@ def cleanup_pending_tool_state(self):
with engine.begin() as conn:
deleted = PendingToolStateRepository(conn).cleanup_expired()
return {"deleted": deleted}
@celery.task(bind=True)
def version_check_task(self):
"""Periodic anonymous version check.
Complements the ``worker_ready`` boot trigger so long-running
deployments (>6h cache TTL) still refresh advisories. ``run_check``
is fail-silent and coordinates across replicas via Redis lock +
cache (see ``application.updates.version_check``).
"""
from application.updates.version_check import run_check
run_check()

View File

@@ -1,9 +1,11 @@
"""Anonymous startup version-check client.
"""Anonymous version-check client.
Called once per Celery worker boot (see ``application/celery_init.py``
``worker_ready`` handler). Posts the running version + anonymous
instance UUID to ``gptcloud.arc53.com/api/check``, caches the response
in Redis, and surfaces any advisories to stdout + logs.
Fired on every Celery worker boot (see ``application/celery_init.py``
``worker_ready`` handler) and on a 7h periodic schedule (see the
``version-check`` entry in ``application/api/user/tasks.py``). Posts
the running version + anonymous instance UUID to
``gptcloud.arc53.com/api/check``, caches the response in Redis, and
surfaces any advisories to stdout + logs.
Design invariants — all enforced by a broad ``try/except`` at the top
of :func:`run_check`: