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() {
|
func (s *Service) RegisterHealthChecks() {
|
||||||
go func() { // startup register
|
go func() { // startup register
|
||||||
s.hcTicker = time.NewTicker(time.Second)
|
t := time.NewTicker(time.Second)
|
||||||
for range s.hcTicker.C {
|
for range t.C {
|
||||||
if ok, _ := s.healthCheck(); ok {
|
if ok, _ := s.healthCheck(); ok {
|
||||||
fmt.Println("Stoping HC Ticker goroutine")
|
t.Stop()
|
||||||
s.hcTicker.Stop()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() { // TTL
|
go func() { // TTL
|
||||||
s.ttlTicker = time.NewTicker(s.ttl)
|
t := time.NewTicker(s.ttl)
|
||||||
for range s.ttlTicker.C {
|
for range t.C {
|
||||||
if _, err := s.healthCheck(); err != nil {
|
if _, err := s.healthCheck(); err != nil {
|
||||||
fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
|
// fmt.Printf("HealthCheck endpoint not available (%s)#: %v\n", s.GetFullAddr(), err)
|
||||||
s.ttlTicker.Stop()
|
t.Stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user