fix(cron): trust the gateway runtime lock for builtin-ticker liveness
_builtin_gateway_liveness() decides whether the builtin cron ticker can fire by PID-scanning via find_gateway_pids(). That scan can transiently return empty even while the gateway is up (e.g. just after a restart), so the in-gateway cronjob tool emits a false 'Gateway is not running — jobs won't fire' while jobs are firing on time. Prefer the gateway runtime lock: it is held for exactly the gateway's lifetime (a reliable liveness signal), and inside the gateway process it short-circuits to True, so the in-gateway check can never false-alarm. Fall back to the PID scan only when the lock reads inactive (the external-CLI path).
This commit is contained in:
committed by
kshitij
parent
74ec63fe18
commit
b71c3cc13c
@@ -78,6 +78,15 @@ def _builtin_gateway_liveness() -> Optional[bool]:
|
||||
try:
|
||||
if _active_cron_provider_name() != "builtin":
|
||||
return True # external provider fires jobs without the gateway
|
||||
# The gateway runtime lock is held for exactly the gateway's lifetime, so it
|
||||
# is a more reliable "is the ticker's process alive" signal than PID scanning
|
||||
# — and inside the gateway process it short-circuits to True, so the in-gateway
|
||||
# cron tool never emits a false "gateway not running" (find_gateway_pids can
|
||||
# transiently miss the gateway just after a restart).
|
||||
from gateway.status import is_gateway_runtime_lock_active
|
||||
|
||||
if is_gateway_runtime_lock_active():
|
||||
return True
|
||||
from hermes_cli.gateway import find_gateway_pids
|
||||
|
||||
return bool(find_gateway_pids())
|
||||
|
||||
Reference in New Issue
Block a user