From 93f4eb0a0f834f06c62042aa62ca39ace91cb567 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 11 Jun 2014 10:17:58 -0700 Subject: [PATCH] consul: Start RPC before Raft, wait to accept connecitons --- consul/server.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/consul/server.go b/consul/server.go index dad30d2f49..e7dd195f34 100644 --- a/consul/server.go +++ b/consul/server.go @@ -177,6 +177,12 @@ func NewServer(config *Config) (*Server, error) { shutdownCh: make(chan struct{}), } + // Initialize the RPC layer + if err := s.setupRPC(tlsConfig); err != nil { + s.Shutdown() + return nil, fmt.Errorf("Failed to start RPC layer: %v", err) + } + // Initialize the Raft server if err := s.setupRaft(); err != nil { s.Shutdown() @@ -203,12 +209,8 @@ func NewServer(config *Config) (*Server, error) { return nil, fmt.Errorf("Failed to start wan serf: %v", err) } - // Initialize the RPC layer - if err := s.setupRPC(tlsConfig); err != nil { - s.Shutdown() - return nil, fmt.Errorf("Failed to start RPC layer: %v", err) - } - + // Start listening for RPC requests + go s.listen() return s, nil } @@ -369,7 +371,6 @@ func (s *Server) setupRPC(tlsConfig *tls.Config) error { } s.raftLayer = NewRaftLayer(advertise, tlsConfig) - go s.listen() return nil }