register fix
This commit is contained in:
parent
a4f4b6e059
commit
ad4368cdf8
@ -36,6 +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)
|
||||
s.ConsulAgent = client.Agent()
|
||||
|
||||
return s, nil
|
||||
@ -72,6 +77,7 @@ func (s *Service) Register() error {
|
||||
if err := s.ConsulAgent.ServiceRegister(def); err != nil {
|
||||
return err
|
||||
}
|
||||
// s.ConsulAgent.
|
||||
go s.UpdateTTL(def)
|
||||
|
||||
return nil
|
||||
@ -120,8 +126,11 @@ func (s *Service) check() (bool, error) {
|
||||
|
||||
func (s *Service) getMetadata() map[string]string {
|
||||
m := map[string]string{}
|
||||
key := fmt.Sprintf(`traefik/http/services/%s/loadBalancer/servers/0/url`, s.Name)
|
||||
m[key] = s.GetFullAddr()
|
||||
m[`traefik_dwa`] = "a"
|
||||
|
||||
// key := "traefik%2Ftest"
|
||||
// key := "traefik/http/services/" + s.Name + "/loadBalancer/servers/0/url"
|
||||
// m[key] = s.GetFullAddr()
|
||||
|
||||
fmt.Printf("netadata: %v", m)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user