@marcel91200 / caddy Mirror · read-only / commits / 7f364c77
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 01:30 UTC

core: Load config at interval instead of just once

Matthew Holt committed Nov 16, 2021 at 13:08 UTC 7f364c777acfc1a0c8c3c62d9c3ad001fb1ea6df
1 file changed +12 -9
caddy.go
+12 -9
@@ -493,17 +493,20 @@ func finishSettingUp(ctx Context, cfg *Config) error {
493 }
494 if cfg.Admin.Config.LoadInterval > 0 {
495 go func() {
496 - select {
497 - // if LoadInterval is positive, will wait for the interval and then run with new config
498 - case <-time.After(time.Duration(cfg.Admin.Config.LoadInterval)):
499 - loadedConfig, err := val.(ConfigLoader).LoadConfig(ctx)
500 - if err != nil {
501 - Log().Error("loading dynamic config failed", zap.Error(err))
496 + for {
497 + select {
498 + // if LoadInterval is positive, will wait for the interval and then run with new config
499 + case <-time.After(time.Duration(cfg.Admin.Config.LoadInterval)):
500 + loadedConfig, err := val.(ConfigLoader).LoadConfig(ctx)
501 + if err != nil {
502 + Log().Error("loading dynamic config failed", zap.Error(err))
503 + return
504 + }
505 + runLoadedConfig(loadedConfig)
506 + case <-ctx.Done():
507 + Log().Info("stopping config load interval")
508 return
509 }
504 - runLoadedConfig(loadedConfig)
505 - case <-ctx.Done():
506 - return
510 }
511 }()
512 } else {