This commit is contained in:
Your Name
2026-04-17 16:17:19 +08:00
parent 0e096947fc
commit bd6bcb240f
17 changed files with 863 additions and 23 deletions

View File

@@ -1,3 +1,5 @@
from __future__ import annotations
from uuid import uuid4
from fastapi import APIRouter

View File

@@ -28,11 +28,13 @@ def fetch_overview() -> dict:
online_worker_nodes = int(cluster_summary.get("online_worker_nodes", 0) or 0)
dedicated_online_worker_nodes = int(cluster_summary.get("dedicated_online_worker_nodes", 0) or 0)
result["worker_status"] = "online" if runtime["worker"]["running"] else "offline"
result["local_worker_status"] = result["worker_status"]
result["local_worker_status"] = "not-applicable" if not runtime["worker"].get("expected_on_this_node", True) else result["worker_status"]
result["cluster_worker_status"] = "online" if online_worker_nodes > 0 else "offline"
result["cluster_online_worker_nodes"] = online_worker_nodes
result["cluster_dedicated_online_worker_nodes"] = dedicated_online_worker_nodes
result["cluster_online_control_nodes"] = int(cluster_summary.get("online_control_nodes", 0) or 0)
result["api_status"] = "online"
result["worker_mode"] = runtime["worker"]["mode"]
result["node_region"] = runtime["node"]["region"]
result["node_role"] = runtime["node"]["role"]
return result

View File

@@ -270,6 +270,7 @@ def get_runtime_status() -> dict:
runtime_settings = get_runtime_settings()
worker_runtime = detect_worker_runtime()
sync_agent_runtime = detect_sync_agent_runtime()
worker_expected_on_this_node = not (settings.node_region == "overseas" and settings.node_role == "control")
api_pid = os.getpid()
detect_snapshot = get_detect_status()
latest_run = (detect_snapshot.get("runs") or [None])[0] or {}
@@ -314,6 +315,35 @@ def get_runtime_status() -> dict:
"queue_health": queue_health,
"capacity_plan": capacity_plan,
}
if not worker_expected_on_this_node:
detect_payload.update(
{
"phase_label": "当前节点不承载",
"phase_detail": "当前节点为海外控制面,仅承载 API 控制与同步接收,不执行本机检测任务。",
"recent_event": "",
"recent_warning": "",
"progress_percent": 0,
"active_thread_count": 0,
"max_thread_count": 0,
"available_proxy_count": 0,
"proxy_pool_count": 0,
"proxy_runtime_label": "不适用",
"proxy_runtime_detail": "当前节点不承载本机 Worker代理、线程与检测阶段信息在此节点上不适用。",
"proxy_runtime_reason": "not_applicable",
"proxy_supplier_empty": False,
"proxy_last_refresh_status": "",
"proxy_last_refresh_time": "",
"proxy_last_refresh_source_count": 0,
"proxy_last_refresh_total_items": 0,
"proxy_last_validated_count": 0,
"proxy_last_available_count": 0,
"proxy_source_stats": [],
"dependency_alerts": [],
"active_job": None,
"runs_count": 0,
"worker_online": False,
}
)
detect_payload["participating_nodes"] = _build_participating_detect_nodes(
cluster_snapshot=cluster_snapshot,
detect_snapshot=detect_payload,
@@ -351,6 +381,7 @@ def get_runtime_status() -> dict:
"mode": worker_runtime.get("mode", runtime_settings.get("worker_mode", "windows-local")),
"service_name": runtime_settings.get("worker_service_name", settings.worker_service_name),
"running": worker_runtime.get("running", False),
"expected_on_this_node": worker_expected_on_this_node,
"process_count": worker_runtime.get("process_count", 0),
"latest_start_time": worker_runtime.get("latest_start_time", ""),
"message": worker_runtime.get("message", ""),