Skip to content

Commit

Permalink
Fixed bug with rendering
Browse files Browse the repository at this point in the history
docklistener was started too early, no receiver on channels.
  • Loading branch information
byrnedo committed Oct 26, 2015
1 parent 2825510 commit 15b44cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docklistener/docklistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func Init(docker *goDocker.Client, newContChan chan<- *goDocker.Container, remov
containers, _ := dockerClient.ListContainers(goDocker.ListContainersOptions{})
Info.Println("Listing intial", len(containers), "containers as started")
for _, cont := range containers {
Info.Println("Marking", cont.ID, "as started")
dockerEventChan <- &goDocker.APIEvents{ID: cont.ID, Status: "start"}
//startedContainerChan <- cont.ID
}
Expand Down Expand Up @@ -96,6 +97,7 @@ func dockerEventRoutingRoutine(eventChan <-chan *goDocker.APIEvents, newContaine
case e := <-eventChan:
switch e.Status {
case "start":
Info.Println(e.ID, "started")
cont, err := dockerClient.InspectContainer(e.ID)
if err != nil {
Error.Println("Failed to inspect new container", e.ID, ":", err)
Expand Down
18 changes: 12 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ func (p ContainerSlice) Swap(i, j int) {
}

var (
newContainerChan = make(chan *goDocker.Container)
removeContainerChan = make(chan string)
doneChan = make(chan bool)
uiEventChan = ui.EventCh()
drawStatsChan = make(chan *docklistener.StatsMsg)
newContainerChan chan *goDocker.Container
removeContainerChan chan string
doneChan chan bool
uiEventChan <-chan ui.Event
drawStatsChan chan *docklistener.StatsMsg
)

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

uiView.Align()

docklistener.Init(docker, newContainerChan, removeContainerChan, drawStatsChan)
newContainerChan = make(chan *goDocker.Container)
removeContainerChan = make(chan string)
doneChan = make(chan bool)
uiEventChan = ui.EventCh()
drawStatsChan = make(chan *docklistener.StatsMsg)

// Statistics

Expand Down Expand Up @@ -185,6 +189,8 @@ func main() {
}
go uiRoutine()

docklistener.Init(docker, newContainerChan, removeContainerChan, drawStatsChan)

//setup initial containers
uiView.Render()

Expand Down

0 comments on commit 15b44cc

Please sign in to comment.