Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7bbc717786 | |||
| a1870e07b5 | |||
| 43c8dd3ad0 | |||
| e57e43188c | |||
| 672a350f31 |
@@ -120,19 +120,24 @@ func (s *Service) KV() *consul.KV {
|
|||||||
func (s *Service) healthCheck() (bool, error) {
|
func (s *Service) healthCheck() (bool, error) {
|
||||||
alive := func() bool {
|
alive := func() bool {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
healthUrl := s.GetFullAddr() + "health"
|
healthUrl := fmt.Sprintf("%s%s?name=%s", s.GetFullAddr(), "health", s.Name)
|
||||||
req, err := http.NewRequest(http.MethodGet, healthUrl, nil)
|
req, err := http.NewRequest(http.MethodGet, healthUrl, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
req.Header.Set("User-Agent", "service/internal")
|
req.Header.Set("User-Agent", "service/internal")
|
||||||
|
|
||||||
|
fmt.Printf("Sending HEALTH CHECK request to: %s\n", healthUrl)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
var body []byte
|
||||||
|
resp.Body.Read(body)
|
||||||
|
fmt.Printf("HEALTH CHECK response to: %v -- %v\n", resp, body)
|
||||||
|
|
||||||
return resp.StatusCode == http.StatusOK
|
return resp.StatusCode == http.StatusOK
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user