diff options
author | Matthew Holt <[email protected]> | 2021-11-16 13:08:22 -0700 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2021-11-16 13:08:22 -0700 |
commit | 7f364c777acfc1a0c8c3c62d9c3ad001fb1ea6df (patch) | |
tree | 7fb65934d2e70f12422c3af28eddb916963e25b9 /caddy.go | |
parent | b47af6ef04f818f41932e4152836d43a9be8fe07 (diff) | |
download | caddy-7f364c777acfc1a0c8c3c62d9c3ad001fb1ea6df.tar.gz caddy-7f364c777acfc1a0c8c3c62d9c3ad001fb1ea6df.zip |
core: Load config at interval instead of just once
Diffstat (limited to 'caddy.go')
-rw-r--r-- | caddy.go | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -493,17 +493,20 @@ func finishSettingUp(ctx Context, cfg *Config) error { } if cfg.Admin.Config.LoadInterval > 0 { go func() { - select { - // if LoadInterval is positive, will wait for the interval and then run with new config - case <-time.After(time.Duration(cfg.Admin.Config.LoadInterval)): - loadedConfig, err := val.(ConfigLoader).LoadConfig(ctx) - if err != nil { - Log().Error("loading dynamic config failed", zap.Error(err)) + for { + select { + // if LoadInterval is positive, will wait for the interval and then run with new config + case <-time.After(time.Duration(cfg.Admin.Config.LoadInterval)): + loadedConfig, err := val.(ConfigLoader).LoadConfig(ctx) + if err != nil { + Log().Error("loading dynamic config failed", zap.Error(err)) + return + } + runLoadedConfig(loadedConfig) + case <-ctx.Done(): + Log().Info("stopping config load interval") return } - runLoadedConfig(loadedConfig) - case <-ctx.Done(): - return } }() } else { |