From 3e2b2fdb867a325fa5a1cb41c44aaafcac18cd93 Mon Sep 17 00:00:00 2001 From: Evan Gilman Date: Mon, 15 Aug 2016 16:15:03 -0700 Subject: [PATCH] Use bind address for consul service checks --- command/agent/agent.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/command/agent/agent.go b/command/agent/agent.go index 49a28cac8..510c6482e 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -434,6 +434,16 @@ func (a *Agent) setupServer() error { }, }, } + // Resolve ServiceCheck addresses + if a.config.Addresses.HTTP != "" && a.config.Addresses.HTTP != "0.0.0.0" { + httpServ.Checks[0].PortLabel = net.JoinHostPort(a.config.Addresses.HTTP, strconv.Itoa(a.config.Ports.HTTP)) + } + if a.config.Addresses.RPC != "" && a.config.Addresses.RPC != "0.0.0.0" { + rpcServ.Checks[0].PortLabel = net.JoinHostPort(a.config.Addresses.RPC, strconv.Itoa(a.config.Ports.RPC)) + } + if a.config.Addresses.Serf != "" && a.config.Addresses.Serf != "0.0.0.0" { + serfServ.Checks[0].PortLabel = net.JoinHostPort(a.config.Addresses.Serf, strconv.Itoa(a.config.Ports.Serf)) + } a.consulSyncer.SetServices(consul.ServerDomain, map[consul.ServiceKey]*structs.Service{ consul.GenerateServiceKey(httpServ): httpServ, consul.GenerateServiceKey(rpcServ): rpcServ,