Skip to content

Commit 15b44cc

Browse files
author
Donal Byrne
committed
Fixed bug with rendering
docklistener was started too early, no receiver on channels.
1 parent 2825510 commit 15b44cc

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

docklistener/docklistener.go

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func Init(docker *goDocker.Client, newContChan chan<- *goDocker.Container, remov
6464
containers, _ := dockerClient.ListContainers(goDocker.ListContainersOptions{})
6565
Info.Println("Listing intial", len(containers), "containers as started")
6666
for _, cont := range containers {
67+
Info.Println("Marking", cont.ID, "as started")
6768
dockerEventChan <- &goDocker.APIEvents{ID: cont.ID, Status: "start"}
6869
//startedContainerChan <- cont.ID
6970
}
@@ -96,6 +97,7 @@ func dockerEventRoutingRoutine(eventChan <-chan *goDocker.APIEvents, newContaine
9697
case e := <-eventChan:
9798
switch e.Status {
9899
case "start":
100+
Info.Println(e.ID, "started")
99101
cont, err := dockerClient.InspectContainer(e.ID)
100102
if err != nil {
101103
Error.Println("Failed to inspect new container", e.ID, ":", err)

main.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ func (p ContainerSlice) Swap(i, j int) {
3737
}
3838

3939
var (
40-
newContainerChan = make(chan *goDocker.Container)
41-
removeContainerChan = make(chan string)
42-
doneChan = make(chan bool)
43-
uiEventChan = ui.EventCh()
44-
drawStatsChan = make(chan *docklistener.StatsMsg)
40+
newContainerChan chan *goDocker.Container
41+
removeContainerChan chan string
42+
doneChan chan bool
43+
uiEventChan <-chan ui.Event
44+
drawStatsChan chan *docklistener.StatsMsg
4545
)
4646

4747
func mapValuesSorted(mapToSort map[string]*goDocker.Container) (sorted ContainerSlice) {
@@ -96,7 +96,11 @@ func main() {
9696

9797
uiView.Align()
9898

99-
docklistener.Init(docker, newContainerChan, removeContainerChan, drawStatsChan)
99+
newContainerChan = make(chan *goDocker.Container)
100+
removeContainerChan = make(chan string)
101+
doneChan = make(chan bool)
102+
uiEventChan = ui.EventCh()
103+
drawStatsChan = make(chan *docklistener.StatsMsg)
100104

101105
// Statistics
102106

@@ -185,6 +189,8 @@ func main() {
185189
}
186190
go uiRoutine()
187191

192+
docklistener.Init(docker, newContainerChan, removeContainerChan, drawStatsChan)
193+
188194
//setup initial containers
189195
uiView.Render()
190196

0 commit comments

Comments
 (0)