cleanup router watcher logic
This commit is contained in:
parent
e7cc3c2210
commit
fc67593ee4
@ -570,19 +570,12 @@ func (r *rtr) start() error {
|
||||
}()
|
||||
|
||||
go func() {
|
||||
var err error
|
||||
var w registry.Watcher
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-r.exit:
|
||||
if w != nil {
|
||||
w.Stop()
|
||||
}
|
||||
return
|
||||
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 logger.V(logger.WarnLevel, logger.DefaultLogger) {
|
||||
logger.Warnf("failed creating registry watcher: %v", err)
|
||||
@ -590,19 +583,14 @@ func (r *rtr) start() error {
|
||||
time.Sleep(time.Second)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// watchRegistry calls stop when it's done
|
||||
if err := r.watchRegistry(w); err != nil {
|
||||
if logger.V(logger.WarnLevel, logger.DefaultLogger) {
|
||||
logger.Warnf("Error watching the registry: %v", err)
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
if w != nil {
|
||||
w.Stop()
|
||||
w = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user