mirror of https://github.com/status-im/consul.git
Auto-register the consul service
This commit is contained in:
parent
0f0f29eb31
commit
8c6f03ad07
|
@ -253,7 +253,11 @@ func TestCatalogListServices(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
if len(out) != 1 {
|
||||
if len(out) != 2 {
|
||||
t.Fatalf("bad: %v", out)
|
||||
}
|
||||
// Consul service should auto-register
|
||||
if len(out["consul"]) != 1 {
|
||||
t.Fatalf("bad: %v", out)
|
||||
}
|
||||
if len(out["db"]) != 1 {
|
||||
|
|
|
@ -132,11 +132,21 @@ func (s *Server) handleAliveMember(member serf.Member) error {
|
|||
}
|
||||
s.logger.Printf("[INFO] consul: member '%s' joined, marking health alive", member.Name)
|
||||
|
||||
// Register consul service if a server
|
||||
var service *structs.NodeService
|
||||
if valid, _, port := isConsulServer(member); valid {
|
||||
service = &structs.NodeService{
|
||||
Service: "consul",
|
||||
Port: port,
|
||||
}
|
||||
}
|
||||
|
||||
// Register with the catalog
|
||||
req := structs.RegisterRequest{
|
||||
Datacenter: s.config.Datacenter,
|
||||
Node: member.Name,
|
||||
Address: member.Addr.String(),
|
||||
Service: service,
|
||||
Check: &structs.HealthCheck{
|
||||
Node: member.Name,
|
||||
CheckID: serfCheckID,
|
||||
|
|
Loading…
Reference in New Issue