Merge pull request #127 from mjarkk/origin/f115

Allow user setting the pull interval
This commit is contained in:
Jesse Duffield 2019-07-27 11:48:08 +10:00 committed by GitHub
commit 64863adc2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 11 deletions

View file

@ -13,7 +13,7 @@ Changes to the user config will only take place after closing and re-opening laz
## Default:
```
```yml
gui:
scrollHeight: 2
theme:
@ -53,7 +53,7 @@ oS:
openCommand: open {{filename}}
openLinkCommand: open {{link}}
update:
method: never
dockerRefreshInterval: 100ms
stats:
graphs:
- caption: CPU (%)

View file

@ -53,8 +53,7 @@ type UserConfig struct {
// OS determines what defaults are set for opening files and links
OS OSConfig `yaml:"oS,omitempty"`
// Update is currently not being used, but like lazydocker, it may be used down
// the line to help you update automatically.
// UpdateConfig determines what the default settings are for updating the ui
Update UpdateConfig `yaml:"update,omitempty"`
// Stats determines how long lazydocker will gather container stats for, and
@ -191,10 +190,12 @@ type OSConfig struct {
OpenLinkCommand string `yaml:"openLinkCommand,omitempty"`
}
// UpdateConfig is currently not being used, but may be used down the line to
// allow for automatic updates
// UpdateConfig determines what the default settings are for updating the ui
type UpdateConfig struct {
Method string `yaml:"method,omitempty"`
// RefreshProjectTime determines the time betweens updates of all continues docker commands like docker ps, docker images, etc.
// It expects a valid duration like: 100ms, 2s, 200ns
// for docs see: https://golang.org/pkg/time/#ParseDuration
DockerRefreshInterval time.Duration `yaml:"dockerRefreshInterval,omitempty"`
}
// GraphConfig specifies how to make a graph of recorded container stats
@ -346,7 +347,7 @@ func GetDefaultConfig() UserConfig {
},
OS: GetPlatformDefaultConfig(),
Update: UpdateConfig{
Method: "never",
DockerRefreshInterval: time.Millisecond * 100,
},
Stats: StatsConfig{
MaxDuration: duration,

View file

@ -267,13 +267,14 @@ func (gui *Gui) Run() error {
gui.waitForIntro.Add(1)
}
dockerRefreshInterval := gui.Config.UserConfig.Update.DockerRefreshInterval
go func() {
gui.waitForIntro.Wait()
gui.goEvery(time.Millisecond*50, gui.renderAppStatus)
gui.goEvery(time.Millisecond*30, gui.reRenderMain)
gui.goEvery(time.Millisecond*100, gui.refreshProject)
gui.goEvery(time.Millisecond*100, gui.refreshContainersAndServices)
gui.goEvery(time.Millisecond*100, gui.refreshVolumes)
gui.goEvery(dockerRefreshInterval, gui.refreshProject)
gui.goEvery(dockerRefreshInterval, gui.refreshContainersAndServices)
gui.goEvery(dockerRefreshInterval, gui.refreshVolumes)
gui.goEvery(time.Millisecond*1000, gui.DockerCommand.UpdateContainerDetails)
gui.goEvery(time.Millisecond*1000, gui.checkForContextChange)
}()