From 38be69bad9f3217e541d16becb84dfcd90e5668a Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 18 Nov 2026 17:17:21 +0800 Subject: [PATCH] fix(website): fix java restart log --- agent/app/service/container.go | 2 + agent/app/service/runtime_utils.go | 14 +++++++ agent/utils/docker/docker.go | 12 ++++++ .../src/components/log/container/index.vue | 38 ++++++++++++++++--- frontend/src/lang/modules/en.ts | 2 + frontend/src/lang/modules/es-es.ts | 4 ++ frontend/src/lang/modules/fa.ts | 4 ++ frontend/src/lang/modules/ja.ts | 3 ++ frontend/src/lang/modules/ko.ts | 3 ++ frontend/src/lang/modules/lo.ts | 4 ++ frontend/src/lang/modules/ms.ts | 4 ++ frontend/src/lang/modules/pt-br.ts | 4 ++ frontend/src/lang/modules/ru.ts | 3 ++ frontend/src/lang/modules/tr.ts | 4 ++ frontend/src/lang/modules/zh-Hant.ts | 2 + frontend/src/lang/modules/zh.ts | 2 + .../runtime/components/runtime-status.vue | 5 ++- 17 files changed, 103 insertions(+), 7 deletions(-) diff --git a/agent/app/service/container.go b/agent/app/service/container.go index 0698b8e8e..9645fdc8e 100644 --- a/agent/app/service/container.go +++ b/agent/app/service/container.go @@ -881,6 +881,8 @@ func writeContainerLogMessage(w io.Writer, done <-chan struct{}, messages <-chan // logs before handling its result, or a ready error channel can drop the tail. if err := <-errors; err != nil { _, _ = fmt.Fprintf(w, "event: error\ndata: %v\n\n", err) + } else { + _, _ = fmt.Fprint(w, "event: complete\ndata: {}\n\n") } return false } diff --git a/agent/app/service/runtime_utils.go b/agent/app/service/runtime_utils.go index 4c24d17e4..1d26b62e6 100644 --- a/agent/app/service/runtime_utils.go +++ b/agent/app/service/runtime_utils.go @@ -213,6 +213,18 @@ func runComposeCmdWithLog(operate string, composePath string, logPath string) er return nil } +func updateRuntimeContainerError(cli docker.Client, containerID string, runtime *model.Runtime) { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + message, err := cli.ContainerStateError(ctx, containerID) + if err != nil { + global.LOG.Warnf("Failed to inspect runtime container %s: %v", containerID, err) + return + } + // Clear the old summary when the engine has no error; the UI provides guidance. + runtime.Message = message +} + func SyncRuntimesStatus(runtimes []model.Runtime) error { cli, err := docker.NewClient() if err != nil { @@ -238,6 +250,7 @@ func SyncRuntimesStatus(runtimes []model.Runtime) error { switch contain.State { case "exited": runtimes[index].Status = constant.StatusError + updateRuntimeContainerError(cli, contain.ID, &runtimes[index]) case "running": runtimes[index].Status = constant.StatusRunning case "paused": @@ -285,6 +298,7 @@ func SyncRuntimeContainerStatus(runtime *model.Runtime) error { switch container.State { case "exited": runtime.Status = constant.StatusError + updateRuntimeContainerError(cli, container.ID, runtime) case "running": runtime.Status = constant.StatusRunning case "paused": diff --git a/agent/utils/docker/docker.go b/agent/utils/docker/docker.go index d2501efa1..ab3b7ab1c 100644 --- a/agent/utils/docker/docker.go +++ b/agent/utils/docker/docker.go @@ -78,6 +78,18 @@ func (c Client) Close() { _ = c.cli.Close() } +// ContainerStateError may be empty when the application itself exits unsuccessfully. +func (c Client) ContainerStateError(ctx context.Context, containerID string) (string, error) { + info, err := c.cli.ContainerInspect(ctx, containerID) + if err != nil { + return "", err + } + if info.ContainerJSONBase == nil || info.State == nil { + return "", nil + } + return info.State.Error, nil +} + func (c Client) ListContainersByName(names []string) ([]container.Summary, error) { var ( options container.ListOptions diff --git a/frontend/src/components/log/container/index.vue b/frontend/src/components/log/container/index.vue index 695c7b868..f3f54c702 100644 --- a/frontend/src/components/log/container/index.vue +++ b/frontend/src/components/log/container/index.vue @@ -1,10 +1,10 @@