register fix

This commit is contained in:
Piotr Biernat 2022-12-02 01:20:55 +01:00
parent 65dbbc16df
commit 2204f6116b

View File

@ -35,11 +35,6 @@ func NewService(servAddr, id, name, hostname, domain string, appPort int) (*Serv
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
@ -67,7 +62,7 @@ func (s *Service) Register() error {
Address: s.Address,
Port: s.Port,
Tags: s.getTags(),
Meta: s.getMetadata(),
// Meta: s.getMetadata(),
Check: &consul.AgentServiceCheck{
TTL: s.TTL.String(),
},
@ -76,7 +71,6 @@ func (s *Service) Register() error {
if err := s.ConsulAgent.ServiceRegister(def); err != nil {
return err
}
// s.ConsulAgent.
go s.UpdateTTL(def)
return nil
@ -128,21 +122,11 @@ func (s *Service) check() (bool, error) {
func (s *Service) getMetadata() map[string]string {
m := map[string]string{}
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)
return m
}
func (s *Service) getTags() []string {
// fullName := fmt.Sprintf("%s-%s", s.Name, s.AppID)
// bFullAddr := fmt.Sprintf("http://%s:%d/", s.IP, s.Port) // FIXME: declare one once - dont need to refresh....
tags := []string{
"traefik.enable=true",
"traefik.http.routers." + s.Name + ".rule=Host(`" + s.Domain + "`)",