Skip to content

Commit

Permalink
Merge pull request gliderlabs#642 from dtm/feature/consul_http_method
Browse files Browse the repository at this point in the history
Feature/consul http method
  • Loading branch information
nicofuccella authored Nov 3, 2019
2 parents da90d17 + 93b8a5e commit d0ab720
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ func (r *ConsulAdapter) buildCheck(service *bridge.Service) *consulapi.AgentServ
if timeout := service.Attrs["check_timeout"]; timeout != "" {
check.Timeout = timeout
}
if method := service.Attrs["check_http_method"]; method != "" {
check.Method = method
}
} else if path := service.Attrs["check_https"]; path != "" {
check.HTTP = fmt.Sprintf("https://%s:%d%s", service.IP, service.Port, path)
if timeout := service.Attrs["check_timeout"]; timeout != "" {
check.Timeout = timeout
}
if method := service.Attrs["check_https_method"]; method != "" {
check.Method = method
}
} else if cmd := service.Attrs["check_cmd"]; cmd != "" {
check.Script = fmt.Sprintf("check-cmd %s %s %s", service.Origin.ContainerID[:12], service.Origin.ExposedPort, cmd)
} else if script := service.Attrs["check_script"]; script != "" {
Expand Down
2 changes: 2 additions & 0 deletions docs/user/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ register an HTTP health check with the service.
SERVICE_80_CHECK_HTTP=/health/endpoint/path
SERVICE_80_CHECK_INTERVAL=15s
SERVICE_80_CHECK_TIMEOUT=1s # optional, Consul default used otherwise
SERVICE_80_CHECK_HTTP_METHOD=HEAD # optional, Consul default used otherwise
```

It works for services on any port, not just 80. If its the only service,
Expand All @@ -51,6 +52,7 @@ register an HTTPS health check with the service.
SERVICE_443_CHECK_HTTPS=/health/endpoint/path
SERVICE_443_CHECK_INTERVAL=15s
SERVICE_443_CHECK_TIMEOUT=1s # optional, Consul default used otherwise
SERVICE_443_CHECK_HTTPS_METHOD=HEAD # optional, Consul default used otherwise
```

### Consul TCP Check
Expand Down

0 comments on commit d0ab720

Please sign in to comment.