From 34ace207a78e76d5efe355ca7ef7390166010469 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Thu, 1 Dec 2022 23:12:53 +0100 Subject: [PATCH] register fix --- consul/discovery.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/consul/discovery.go b/consul/discovery.go index 7a4160a..c043579 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -36,11 +36,11 @@ func NewService(serverAddr, appID, appName, ip, domain string, appPort int) (*Se if err != nil { return nil, err } - kv := client.KV() - obj := new(consul.KVPair) - obj.Key = "traefik/http/services/" + s.Name + "/loadBalancer/servers/0/url" - obj.Value = []byte(s.GetFullAddr()) - kv.Put(obj, nil) + // kv := client.KV() + // obj := new(consul.KVPair) + // obj.Key = "traefik/http/services/" + s.Name + "/loadBalancer/servers/0/url" + // obj.Value = []byte(s.GetFullAddr()) + // kv.Put(obj, nil) s.ConsulAgent = client.Agent() return s, nil @@ -93,10 +93,12 @@ func (s *Service) UpdateTTL(service *consul.AgentServiceRegistration) { if !ok { if err := s.ConsulAgent.FailTTL("service:"+s.GetID(), err.Error()); err != nil { log.Println(err) + fmt.Println(err) } } else { if err := s.ConsulAgent.PassTTL("service:"+s.GetID(), "OK"); err != nil { log.Println(err) + fmt.Println(err) } } } @@ -104,7 +106,8 @@ func (s *Service) UpdateTTL(service *consul.AgentServiceRegistration) { func (s *Service) check() (bool, error) { client := &http.Client{} - healthUrl := fmt.Sprintf("http://%s/health", s.GetFullAddr()) + healthUrl := fmt.Sprintf("%shealth", s.GetFullAddr()) + fmt.Println("HCheck: " + healthUrl) req, err := http.NewRequest(http.MethodGet, healthUrl, nil) if err != nil { return false, ErrServiceUnavailable @@ -132,7 +135,7 @@ func (s *Service) getMetadata() map[string]string { // key := "traefik/http/services/" + s.Name + "/loadBalancer/servers/0/url" // m[key] = s.GetFullAddr() - fmt.Printf("netadata: %v", m) + // fmt.Printf("netadata: %v", m) return m }