From 28641a7ab19f213e1de7f2e8c737921536182d4b Mon Sep 17 00:00:00 2001 From: haoliang <821644@qq.com> Date: Sat, 2 May 2026 22:26:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=87=E9=9B=86=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=8A=B6=E6=80=81=E4=B8=8D=E6=98=BE=E7=A4=BA=EF=BC=9A?= =?UTF-8?q?serviceId=E4=B8=8E=E5=BF=83=E8=B7=B3=E6=9F=A5=E8=AF=A2=E4=B8=8D?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=EF=BC=8CAPI=E8=BF=94=E5=9B=9E=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=B8=8E=E5=89=8D=E7=AB=AF=E4=B8=8D=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CncCollector/Config/CollectorConfig.cs | 2 +- src/CncService/Impl/DashboardService.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/CncCollector/Config/CollectorConfig.cs b/src/CncCollector/Config/CollectorConfig.cs index 0e477f5..1c23bed 100644 --- a/src/CncCollector/Config/CollectorConfig.cs +++ b/src/CncCollector/Config/CollectorConfig.cs @@ -39,7 +39,7 @@ namespace CncCollector.Config /// 服务ID标识 [JsonProperty("serviceId")] - public string ServiceId { get; set; } = "CncCollector"; + public string ServiceId { get; set; } = "collector-service"; // ===== 以下为从DB加载的运行时配置 ===== diff --git a/src/CncService/Impl/DashboardService.cs b/src/CncService/Impl/DashboardService.cs index e7f0394..78e346f 100644 --- a/src/CncService/Impl/DashboardService.cs +++ b/src/CncService/Impl/DashboardService.cs @@ -75,7 +75,12 @@ namespace CncService.Impl var latest = _collectorHeartbeatRepository.GetLatest("collector-service"); bool isRunning = latest != null && latest.LastCollectTime.HasValue && (DateTime.Now - latest.LastCollectTime.Value).TotalMinutes < 5; - return new { IsRunning = isRunning, LastCollectTime = latest?.LastCollectTime }; + long uptimeSeconds = 0; + if (isRunning && latest != null) + { + uptimeSeconds = latest.UptimeSeconds ?? 0; + } + return new { status = isRunning ? "running" : "stopped", uptimeSeconds, lastCollectTime = latest?.LastCollectTime }; } } }