diff --git a/internal/docker/idlewatcher/container.go b/internal/docker/idlewatcher/container.go index 6a8ca1e..a0245fe 100644 --- a/internal/docker/idlewatcher/container.go +++ b/internal/docker/idlewatcher/container.go @@ -7,6 +7,17 @@ import ( "github.com/docker/docker/api/types/container" ) +type ( + containerMeta struct { + ContainerID, ContainerName string + } + containerState struct { + running bool + ready bool + err error + } +) + func (w *Watcher) containerStop(ctx context.Context) error { return w.client.ContainerStop(ctx, w.ContainerID, container.StopOptions{ Signal: string(w.StopSignal), diff --git a/internal/docker/idlewatcher/waker.go b/internal/docker/idlewatcher/waker.go index dd4c009..e535a2a 100644 --- a/internal/docker/idlewatcher/waker.go +++ b/internal/docker/idlewatcher/waker.go @@ -134,6 +134,10 @@ func (w *Watcher) checkUpdateState() (ready bool, err error) { return true, nil } + if !w.running() { + return false, nil + } + if w.metric != nil { defer w.metric.Set(float64(w.Status())) } diff --git a/internal/docker/idlewatcher/watcher.go b/internal/docker/idlewatcher/watcher.go index a60832f..0f12a03 100644 --- a/internal/docker/idlewatcher/watcher.go +++ b/internal/docker/idlewatcher/watcher.go @@ -37,14 +37,6 @@ type ( lastReset time.Time task *task.Task } - containerMeta struct { - ContainerID, ContainerName string - } - containerState struct { - running bool - ready bool - err error - } StopCallback func() error )