mirror of https://github.com/caddyserver/caddy.git
core: Load config at interval instead of just once
This commit is contained in:
parent
b47af6ef04
commit
7f364c777a
21
caddy.go
21
caddy.go
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue