cleanup router watcher logic
This commit is contained in:
parent
1519dcb3e1
commit
3761461d15
26
registry.go
26
registry.go
@ -570,39 +570,27 @@ func (r *rtr) start() error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
var err error
|
|
||||||
var w registry.Watcher
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-r.exit:
|
case <-r.exit:
|
||||||
if w != nil {
|
|
||||||
w.Stop()
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
if w == nil {
|
w, err := r.options.Registry.Watch(registry.WatchDomain(registry.WildcardDomain))
|
||||||
w, err = r.options.Registry.Watch(registry.WatchDomain(registry.WildcardDomain))
|
if err != nil {
|
||||||
if err != nil {
|
if logger.V(logger.WarnLevel, logger.DefaultLogger) {
|
||||||
if logger.V(logger.WarnLevel, logger.DefaultLogger) {
|
logger.Warnf("failed creating registry watcher: %v", err)
|
||||||
logger.Warnf("failed creating registry watcher: %v", err)
|
|
||||||
}
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// watchRegistry calls stop when it's done
|
||||||
if err := r.watchRegistry(w); err != nil {
|
if err := r.watchRegistry(w); err != nil {
|
||||||
if logger.V(logger.WarnLevel, logger.DefaultLogger) {
|
if logger.V(logger.WarnLevel, logger.DefaultLogger) {
|
||||||
logger.Warnf("Error watching the registry: %v", err)
|
logger.Warnf("Error watching the registry: %v", err)
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
if w != nil {
|
|
||||||
w.Stop()
|
|
||||||
w = nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user