plugin/auto: Reload zones every one minute (#2516)

Automatically submitted.
This commit is contained in:
mrasu
2019-02-17 23:51:47 +09:00
committed by corbot[bot]
parent 643dfd7419
commit 362d7e96dc
3 changed files with 66 additions and 24 deletions

View File

@@ -77,9 +77,15 @@ func setup(c *caddy.Controller) error {
}
func autoParse(c *caddy.Controller) (Auto, error) {
nilInterval := -1 * time.Second
var a = Auto{
loader: loader{template: "${1}", re: regexp.MustCompile(`db\.(.*)`), duration: 60 * time.Second},
Zones: &Zones{},
loader: loader{
template: "${1}",
re: regexp.MustCompile(`db\.(.*)`),
ReloadInterval: nilInterval,
duration: nilInterval,
},
Zones: &Zones{},
}
config := dnsserver.GetConfig(c)
@@ -141,6 +147,7 @@ func autoParse(c *caddy.Controller) (Auto, error) {
if i < 1 {
i = 1
}
log.Warning("TIMEOUT of directory is deprecated. Use RELOAD instead. See https://coredns.io/plugins/auto/#syntax")
a.loader.duration = time.Duration(i) * time.Second
}
@@ -169,5 +176,15 @@ func autoParse(c *caddy.Controller) (Auto, error) {
}
}
}
if a.loader.ReloadInterval == nilInterval {
if a.loader.duration == nilInterval {
a.loader.duration = 60 * time.Second
}
a.loader.ReloadInterval = a.loader.duration
} else if a.loader.duration == nilInterval {
a.loader.duration = a.loader.ReloadInterval
}
return a, nil
}