Skip to content

Commit

Permalink
Merge pull request #357 from nautsio/consul_tcp_health_check
Browse files Browse the repository at this point in the history
added Consul TCP Health Check
  • Loading branch information
mattatcha committed Mar 5, 2016
2 parents 0a99627 + 3b65f7d commit 7513e42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ func (r *ConsulAdapter) buildCheck(service *bridge.Service) *consulapi.AgentServ
check.Script = r.interpolateService(script, service)
} else if ttl := service.Attrs["check_ttl"]; ttl != "" {
check.TTL = ttl
} else if tcp := service.Attrs["check_tcp"]; tcp != "" {
check.TCP = fmt.Sprintf("%s:%d", service.IP, service.Port)
if timeout := service.Attrs["check_timeout"]; timeout != "" {
check.Timeout = timeout
}
} else {
return nil
}
if check.Script != "" || check.HTTP != "" {
if check.Script != "" || check.HTTP != "" || check.TCP != "" {
if interval := service.Attrs["check_interval"]; interval != "" {
check.Interval = interval
} else {
Expand Down
12 changes: 12 additions & 0 deletions docs/user/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ SERVICE_80_CHECK_TIMEOUT=1s # optional, Consul default used otherwise
It works for services on any port, not just 80. If its the only service,
you can also use `SERVICE_CHECK_HTTP`.

### Consul TCP Check

This feature is only available when using Consul 0.6 or newer. Containers
specifying these extra metadata in labels or environment will be used to
register an TCP health check with the service.

```bash
SERVICE_443_CHECK_TCP=true
SERVICE_443_CHECK_INTERVAL=15s
SERVICE_443_CHECK_TIMEOUT=3s # optional, Consul default used otherwise
```

### Consul Script Check

This feature is tricky because it lets you specify a script check to run from
Expand Down

0 comments on commit 7513e42

Please sign in to comment.