fix in consul discovery
This commit is contained in:
parent
eb763ed49c
commit
3afe78f9e3
@ -115,21 +115,20 @@ func (s *Service) Unregister() error {
|
||||
|
||||
func (s *Service) RegisterHealthChecks() {
|
||||
go func() { // startup register
|
||||
s.hcTicker = time.NewTicker(time.Second)
|
||||
for range s.hcTicker.C {
|
||||
t := time.NewTicker(time.Second)
|
||||
for range t.C {
|
||||
if ok, _ := s.healthCheck(); ok {
|
||||
fmt.Println("Stoping HC Ticker goroutine")
|
||||
s.hcTicker.Stop()
|
||||
t.Stop()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
go func() { // TTL
|
||||
s.ttlTicker = time.NewTicker(s.ttl)
|
||||
for range s.ttlTicker.C {
|
||||
t := time.NewTicker(s.ttl)
|
||||
for range t.C {
|
||||
if _, err := s.healthCheck(); err != nil {
|
||||
fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
|
||||
s.ttlTicker.Stop()
|
||||
// fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
|
||||
t.Stop()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user