diff --git a/internal/pkg/core/context.go b/internal/pkg/core/context.go index d74a5c2..0cc59bf 100644 --- a/internal/pkg/core/context.go +++ b/internal/pkg/core/context.go @@ -384,10 +384,11 @@ func (c *context) URI() string { return uri } -// RequestContext 获取请求的 context (当client关闭后,会自动canceled) +// RequestContext (包装 Trace + Logger) 获取请求的 context (当client关闭后,会自动canceled) func (c *context) RequestContext() StdContext { return StdContext{ - c.ctx.Request.Context(), + //c.ctx.Request.Context(), + stdctx.Background(), c.Trace(), c.Logger(), } diff --git a/internal/web/controller/dashboard_handler/func_view.go b/internal/web/controller/dashboard_handler/func_view.go index fc32826..b782b3d 100644 --- a/internal/web/controller/dashboard_handler/func_view.go +++ b/internal/web/controller/dashboard_handler/func_view.go @@ -70,9 +70,14 @@ func (h *handler) View() core.HandlerFunc { obj.HostOS = fmt.Sprintf("%s(%s) %s", hostInfo.Platform, hostInfo.PlatformFamily, hostInfo.PlatformVersion) obj.HostName = hostInfo.Hostname - obj.CpuName = cpuInfo[0].ModelName - obj.CpuCores = cpuInfo[0].Cores - obj.CpuUsedPercent, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cpuPercent[0]), 64) + if len(cpuInfo) > 0 { + obj.CpuName = cpuInfo[0].ModelName + obj.CpuCores = cpuInfo[0].Cores + } + + if len(cpuPercent) > 0 { + obj.CpuUsedPercent, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cpuPercent[0]), 64) + } obj.GoPath = runtime.GOROOT() obj.GoVersion = runtime.Version()