Compare commits

...

2 Commits

Author SHA1 Message Date
7a35d1f44a Consul debug 2023-06-28 22:54:58 +02:00
7bfd048051 Consul debug 2023-06-28 22:50:16 +02:00

View File

@@ -92,7 +92,7 @@ func (s *Service) Register() error {
ticker := time.NewTicker(interval) ticker := time.NewTicker(interval)
for range ticker.C { for range ticker.C {
if _, err := s.healthCheck(); err != nil { if _, err := s.healthCheck(); err != nil {
fmt.Printf("TTL Error: %v\n", err) fmt.Printf("TTL Error #: %v\n", err)
} }
} }
}(s) }(s)
@@ -115,14 +115,17 @@ func (s *Service) healthCheck() (bool, error) {
alive := func() bool { alive := func() bool {
client := &http.Client{} client := &http.Client{}
healthUrl := s.GetFullAddr() + "health" healthUrl := s.GetFullAddr() + "health"
fmt.Printf("Sending request to the %s", healthUrl)
req, err := http.NewRequest(http.MethodGet, healthUrl, nil) req, err := http.NewRequest(http.MethodGet, healthUrl, nil)
if err != nil { if err != nil {
fmt.Printf("Failed to create new Consul request: %v\n", err)
return false return false
} }
req.Header.Set("User-Agent", "Health Check") req.Header.Set("User-Agent", "Health Check")
resp, err := client.Do(req) resp, err := client.Do(req)
if err != nil { if err != nil {
fmt.Printf("Failed to send Consul request: %v\n", err)
return false return false
} }
defer resp.Body.Close() defer resp.Body.Close()