fix registry check issue (#1067)
fix #1066 Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
61cde4a9f4
commit
943445270f
@ -835,17 +835,20 @@ func (s *rpcServer) Start() error {
|
||||
s.RLock()
|
||||
registered := s.registered
|
||||
s.RUnlock()
|
||||
if err = s.opts.RegisterCheck(s.opts.Context); err != nil && registered {
|
||||
rerr := s.opts.RegisterCheck(s.opts.Context)
|
||||
if rerr != nil && registered {
|
||||
log.Logf("Server %s-%s register check error: %s, deregister it", config.Name, config.Id, err)
|
||||
// deregister self in case of error
|
||||
if err := s.Deregister(); err != nil {
|
||||
log.Logf("Server %s-%s deregister error: %s", config.Name, config.Id, err)
|
||||
}
|
||||
} else {
|
||||
} else if rerr != nil && !registered {
|
||||
log.Logf("Server %s-%s register check error: %s", config.Name, config.Id, err)
|
||||
continue
|
||||
}
|
||||
if err := s.Register(); err != nil {
|
||||
log.Logf("Server %s-%s register error: %s", config.Name, config.Id, err)
|
||||
}
|
||||
}
|
||||
// wait for exit
|
||||
case ch = <-s.exit:
|
||||
t.Stop()
|
||||
@ -854,10 +857,15 @@ func (s *rpcServer) Start() error {
|
||||
}
|
||||
}
|
||||
|
||||
s.RLock()
|
||||
registered := s.registered
|
||||
s.RUnlock()
|
||||
if registered {
|
||||
// deregister self
|
||||
if err := s.Deregister(); err != nil {
|
||||
log.Logf("Server %s-%s deregister error: %s", config.Name, config.Id, err)
|
||||
}
|
||||
}
|
||||
|
||||
s.Lock()
|
||||
swg := s.wg
|
||||
|
Loading…
Reference in New Issue
Block a user