Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: update health failure handling to use configurable restart threshold

myhlolib18da3c3b664
diff --git a/mineru/cli/router.py b/mineru/cli/router.py
index d28964fb..8d924f3d 100644
--- a/mineru/cli/router.py
+++ b/mineru/cli/router.py
@@ -69,6 +69,7 @@ LOCAL_GPU_NONE = "none"
HTTP_RETRYABLE_STATUS_CODES = {500, 502, 503, 504}
UPSTREAM_FAILURE_THRESHOLD = 3
WORKER_REFRESH_INTERVAL_SECONDS = 2.0
+WORKER_HEALTH_FAILURE_RESTART_THRESHOLD = 5
MIN_HEALTHY_PROCESSING_WINDOW_SIZE = 1
MINERU_ROUTER_PUBLIC_BIND_EXPOSED_ENV = "MINERU_ROUTER_PUBLIC_BIND_EXPOSED"
MINERU_ROUTER_ALLOW_PUBLIC_HTTP_CLIENT_ENV = "MINERU_ROUTER_ALLOW_PUBLIC_HTTP_CLIENT"
@@ -616,7 +617,11 @@ class WorkerPool:
server.last_error = str(exc)
server.last_checked_at = utc_now_iso()
server.consecutive_health_failures += 1
- if server.local_server is not None and server.consecutive_health_failures >= 2:
+ if (
+ server.local_server is not None
+ and server.consecutive_health_failures
+ >= WORKER_HEALTH_FAILURE_RESTART_THRESHOLD
+ ):
await self._restart_local_server(server)
return
@@ -625,7 +630,11 @@ class WorkerPool:
server.healthy = False
server.last_error = response_detail(response)
server.consecutive_health_failures += 1
- if server.local_server is not None and server.consecutive_health_failures >= 2:
+ if (
+ server.local_server is not None
+ and server.consecutive_health_failures
+ >= WORKER_HEALTH_FAILURE_RESTART_THRESHOLD
+ ):
await self._restart_local_server(server)
return
@@ -636,7 +645,11 @@ class WorkerPool:
server.healthy = False
server.last_error = f"Invalid health payload: {exc}"
server.consecutive_health_failures += 1
- if server.local_server is not None and server.consecutive_health_failures >= 2:
+ if (
+ server.local_server is not None
+ and server.consecutive_health_failures
+ >= WORKER_HEALTH_FAILURE_RESTART_THRESHOLD
+ ):
await self._restart_local_server(server)
return