Skip to content

Commit

Permalink
core: Load config at interval instead of just once
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed Nov 16, 2021
1 parent b47af6e commit 7f364c7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions caddy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

1 comment on commit 7f364c7

@mholt
Copy link
Member Author

@mholt mholt commented on 7f364c7 Mar 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not convinced this commit was correct, I think it was a hasty fix for a non-problem. Reverting.

Please sign in to comment.