mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-26 21:53:48 +03:00
core: Load config at interval instead of just once
This commit is contained in:
parent
b47af6ef04
commit
7f364c777a
1 changed files with 12 additions and 9 deletions
21
caddy.go
21
caddy.go
|
@ -493,17 +493,20 @@ func finishSettingUp(ctx Context, cfg *Config) error {
|
||||||
}
|
}
|
||||||
if cfg.Admin.Config.LoadInterval > 0 {
|
if cfg.Admin.Config.LoadInterval > 0 {
|
||||||
go func() {
|
go func() {
|
||||||
select {
|
for {
|
||||||
// if LoadInterval is positive, will wait for the interval and then run with new config
|
select {
|
||||||
case <-time.After(time.Duration(cfg.Admin.Config.LoadInterval)):
|
// if LoadInterval is positive, will wait for the interval and then run with new config
|
||||||
loadedConfig, err := val.(ConfigLoader).LoadConfig(ctx)
|
case <-time.After(time.Duration(cfg.Admin.Config.LoadInterval)):
|
||||||
if err != nil {
|
loadedConfig, err := val.(ConfigLoader).LoadConfig(ctx)
|
||||||
Log().Error("loading dynamic config failed", zap.Error(err))
|
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
|
return
|
||||||
}
|
}
|
||||||
runLoadedConfig(loadedConfig)
|
|
||||||
case <-ctx.Done():
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue