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 }; } } }