mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-18 14:13:10 +00:00
feat: make version check periodic
This commit is contained in:
1 parent
9c8ae9d540
commit
ef976eeb06
2 files changed
+25
-5
No files matched your search
@@ -140,6 +140,11 @@ def setup_periodic_tasks(sender, **kwargs):
|
|||||||
cleanup_pending_tool_state.s(),
|
cleanup_pending_tool_state.s(),
|
||||||
name="cleanup-pending-tool-state",
|
name="cleanup-pending-tool-state",
|
||||||
)
|
)
|
||||||
|
sender.add_periodic_task(
|
||||||
|
timedelta(hours=7),
|
||||||
|
version_check_task.s(),
|
||||||
|
name="version-check",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@celery.task(bind=True)
|
@celery.task(bind=True)
|
||||||
@@ -176,3 +181,16 @@ def cleanup_pending_tool_state(self):
|
|||||||
with engine.begin() as conn:
|
with engine.begin() as conn:
|
||||||
deleted = PendingToolStateRepository(conn).cleanup_expired()
|
deleted = PendingToolStateRepository(conn).cleanup_expired()
|
||||||
return {"deleted": deleted}
|
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()
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
"""Anonymous startup version-check client.
|
"""Anonymous version-check client.
|
||||||
|
|
||||||
Called once per Celery worker boot (see ``application/celery_init.py``
|
Fired on every Celery worker boot (see ``application/celery_init.py``
|
||||||
``worker_ready`` handler). Posts the running version + anonymous
|
``worker_ready`` handler) and on a 7h periodic schedule (see the
|
||||||
instance UUID to ``gptcloud.arc53.com/api/check``, caches the response
|
``version-check`` entry in ``application/api/user/tasks.py``). Posts
|
||||||
in Redis, and surfaces any advisories to stdout + logs.
|
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
|
Design invariants — all enforced by a broad ``try/except`` at the top
|
||||||
of :func:`run_check`:
|
of :func:`run_check`:
|
||||||
|
|||||||
Reference in new issue
Block a user