mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add SetStatus method to Container
This commit is contained in:
parent
dbe657c9e1
commit
3f36e0c1f5
10
container.go
10
container.go
@ -8,6 +8,7 @@ import (
|
||||
type Container struct {
|
||||
id string
|
||||
name string
|
||||
state string
|
||||
metrics collector.Metrics
|
||||
collect collector.Collector
|
||||
widgets widgets.ContainerWidgets
|
||||
@ -21,6 +22,15 @@ func (c *Container) Collapse() {
|
||||
c.widgets = widgets.NewCompact(c.id, c.name)
|
||||
}
|
||||
|
||||
func (c *Container) SetState(s string) {
|
||||
c.state = s
|
||||
c.widgets.SetStatus(s)
|
||||
// start collector if necessary
|
||||
if s == "running" && !c.collect.Running() {
|
||||
c.Collect()
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Container) Collect() {
|
||||
c.collect.Start()
|
||||
go func() {
|
||||
|
@ -62,11 +62,7 @@ func (cm *ContainerMap) Refresh() {
|
||||
removeIDs = append(removeIDs, id)
|
||||
continue
|
||||
}
|
||||
// start collector if necessary
|
||||
if states[id] == "running" && !c.collect.Running() {
|
||||
c.Collect()
|
||||
}
|
||||
c.widgets.SetStatus(states[id])
|
||||
c.SetState(states[id])
|
||||
}
|
||||
|
||||
// remove dead containers
|
||||
|
Loading…
Reference in New Issue
Block a user