mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
remove duplicate inspect, trigger refresh on "health_status" events
This commit is contained in:
parent
626d50d3e9
commit
a1ebf3f90e
@ -45,8 +45,11 @@ func (cm *Docker) watchEvents() {
|
|||||||
if e.Type != "container" {
|
if e.Type != "container" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch e.Action {
|
|
||||||
case "start", "die", "pause", "unpause":
|
actionName := strings.Split(e.Action, ":")[0]
|
||||||
|
|
||||||
|
switch actionName {
|
||||||
|
case "start", "die", "pause", "unpause", "health_status":
|
||||||
log.Debugf("handling docker event: action=%s id=%s", e.Action, e.ID)
|
log.Debugf("handling docker event: action=%s id=%s", e.Action, e.ID)
|
||||||
cm.needsRefresh <- e.ID
|
cm.needsRefresh <- e.ID
|
||||||
case "destroy":
|
case "destroy":
|
||||||
@ -111,7 +114,6 @@ func (cm *Docker) refreshAll() {
|
|||||||
c := cm.MustGet(i.ID)
|
c := cm.MustGet(i.ID)
|
||||||
c.SetMeta("name", shortName(i.Names[0]))
|
c.SetMeta("name", shortName(i.Names[0]))
|
||||||
c.SetState(i.State)
|
c.SetState(i.State)
|
||||||
cm.HealthCheck(i.ID)
|
|
||||||
cm.needsRefresh <- c.Id
|
cm.needsRefresh <- c.Id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,9 +162,6 @@ func (cm *Docker) All() (containers container.Containers) {
|
|||||||
cm.lock.Lock()
|
cm.lock.Lock()
|
||||||
for _, c := range cm.containers {
|
for _, c := range cm.containers {
|
||||||
containers = append(containers, c)
|
containers = append(containers, c)
|
||||||
cm.lock.Unlock()
|
|
||||||
cm.HealthCheck(c.Id)
|
|
||||||
cm.lock.Lock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
containers.Sort()
|
containers.Sort()
|
||||||
@ -175,9 +174,3 @@ func (cm *Docker) All() (containers container.Containers) {
|
|||||||
func shortName(name string) string {
|
func shortName(name string) string {
|
||||||
return strings.Replace(name, "/", "", 1)
|
return strings.Replace(name, "/", "", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *Docker) HealthCheck(id string){
|
|
||||||
insp := cm.inspect(id)
|
|
||||||
c := cm.MustGet(id)
|
|
||||||
c.SetMeta("health", insp.State.Health.Status)
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user