From 32be684fdf0c447192c6b8bff1087b1bf75360fa Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 18 Jan 2017 15:06:15 -0800 Subject: [PATCH] Fixes a startup ordering issue between Raft and Serf. This fixes #2663 and fixes #1899. It's not super related to this PR, but the startup time changes that this PR brings made this a lot worse so I was able to track it down. --- consul/server.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/consul/server.go b/consul/server.go index 18568dfdb5..13d3088052 100644 --- a/consul/server.go +++ b/consul/server.go @@ -284,6 +284,10 @@ func NewServer(config *Config) (*Server, error) { } go s.wanEventHandler() + // Start monitoring leadership. This must happen after Serf is set up + // since it can fire events when leadership is obtained. + go s.monitorLeadership() + // Start ACL replication. if s.IsACLReplicationEnabled() { go s.runACLReplication() @@ -491,9 +495,6 @@ func (s *Server) setupRaft() error { if err != nil { return err } - - // Start monitoring leadership. - go s.monitorLeadership() return nil }