From 26d259b9529dbc277e7a24835f95b10babd5c34c Mon Sep 17 00:00:00 2001 From: yusing Date: Wed, 15 Jan 2025 09:10:26 +0800 Subject: [PATCH] fix: docker monitor now uses container status --- internal/watcher/health/monitor/docker.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/watcher/health/monitor/docker.go b/internal/watcher/health/monitor/docker.go index dd84dbe..bdb7307 100644 --- a/internal/watcher/health/monitor/docker.go +++ b/internal/watcher/health/monitor/docker.go @@ -29,6 +29,19 @@ func (mon *DockerHealthMonitor) CheckHealth() (result *health.HealthCheckResult, if err != nil { return mon.fallback.CheckHealth() } + status := cont.State.Status + switch status { + case "dead", "exited", "paused", "restarting", "removing": + return &health.HealthCheckResult{ + Healthy: false, + Detail: "container is " + status, + }, nil + case "created": + return &health.HealthCheckResult{ + Healthy: false, + Detail: "container is not started", + }, nil + } if cont.State.Health == nil { return mon.fallback.CheckHealth() }