mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 04:52:35 +02:00
idlewatcher/waker: refactor
This commit is contained in:
parent
1078731f2d
commit
d4d2efe925
3 changed files with 15 additions and 8 deletions
|
@ -7,6 +7,17 @@ import (
|
||||||
"github.com/docker/docker/api/types/container"
|
"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 {
|
func (w *Watcher) containerStop(ctx context.Context) error {
|
||||||
return w.client.ContainerStop(ctx, w.ContainerID, container.StopOptions{
|
return w.client.ContainerStop(ctx, w.ContainerID, container.StopOptions{
|
||||||
Signal: string(w.StopSignal),
|
Signal: string(w.StopSignal),
|
||||||
|
|
|
@ -134,6 +134,10 @@ func (w *Watcher) checkUpdateState() (ready bool, err error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !w.running() {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
if w.metric != nil {
|
if w.metric != nil {
|
||||||
defer w.metric.Set(float64(w.Status()))
|
defer w.metric.Set(float64(w.Status()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,14 +37,6 @@ type (
|
||||||
lastReset time.Time
|
lastReset time.Time
|
||||||
task *task.Task
|
task *task.Task
|
||||||
}
|
}
|
||||||
containerMeta struct {
|
|
||||||
ContainerID, ContainerName string
|
|
||||||
}
|
|
||||||
containerState struct {
|
|
||||||
running bool
|
|
||||||
ready bool
|
|
||||||
err error
|
|
||||||
}
|
|
||||||
|
|
||||||
StopCallback func() error
|
StopCallback func() error
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue