slightly more responsive

This commit is contained in:
Jesse Duffield 2021-11-26 21:16:47 +11:00
parent 9db6eeac9d
commit 3c9437f801

View file

@ -178,6 +178,11 @@ func (gui *Gui) renderContainerLogs(container *commands.Container) error {
mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel
return gui.T.NewTickerTask(time.Millisecond*200, nil, func(stop, notifyStopped chan struct{}) { return gui.T.NewTickerTask(time.Millisecond*200, nil, func(stop, notifyStopped chan struct{}) {
gui.renderContainerLogsAux(container, stop, notifyStopped)
})
}
func (gui *Gui) renderContainerLogsAux(container *commands.Container, stop, notifyStopped chan struct{}) {
gui.clearMainView() gui.clearMainView()
command := utils.ApplyTemplate( command := utils.ApplyTemplate(
@ -210,12 +215,13 @@ func (gui *Gui) renderContainerLogs(container *commands.Container) error {
// if we are here because the task has been stopped, we should return // if we are here because the task has been stopped, we should return
// if we are here then the container must have exited, meaning we should wait until it's back again before // if we are here then the container must have exited, meaning we should wait until it's back again before
L: ticker := time.NewTicker(time.Millisecond * 100)
defer ticker.Stop()
for { for {
select { select {
case <-stop: case <-stop:
return return
default: case <-ticker.C:
result, err := container.Inspect() result, err := container.Inspect()
if err != nil { if err != nil {
// if we get an error, then the container has probably been removed so we'll get out of here // if we get an error, then the container has probably been removed so we'll get out of here
@ -224,12 +230,10 @@ func (gui *Gui) renderContainerLogs(container *commands.Container) error {
return return
} }
if result.State.Running { if result.State.Running {
break L return
} }
time.Sleep(time.Millisecond * 100)
} }
} }
})
} }
func (gui *Gui) refreshContainersAndServices() error { func (gui *Gui) refreshContainersAndServices() error {