From dfc165a47b0426a7d65aa9f4b6f6af8915ae52f8 Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Mon, 18 Dec 2017 18:02:17 -0800 Subject: [PATCH] Move autopilot initializing to oss file --- agent/consul/autopilot_oss.go | 9 +++++++++ agent/consul/server.go | 6 +++--- agent/consul/server_oss.go | 8 -------- 3 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 agent/consul/autopilot_oss.go diff --git a/agent/consul/autopilot_oss.go b/agent/consul/autopilot_oss.go new file mode 100644 index 000000000..15c2de4c6 --- /dev/null +++ b/agent/consul/autopilot_oss.go @@ -0,0 +1,9 @@ +// +build !ent +package consul + +import "github.com/hashicorp/consul/agent/consul/autopilot" + +func (s *Server) initAutopilot(config *Config) { + apDelegate := &AutopilotDelegate{s} + s.autopilot = autopilot.NewAutopilot(s.logger, apDelegate, config.AutopilotInterval, config.ServerHealthInterval) +} diff --git a/agent/consul/server.go b/agent/consul/server.go index de7b737d8..59d072741 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -294,9 +294,6 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (* shutdownCh: shutdownCh, } - // Run divergent OSS/Enterprise setup - s.startServerEnterprise(config) - // Initialize the stats fetcher that autopilot will use. s.statsFetcher = NewStatsFetcher(logger, s.connPool, s.config.Datacenter) @@ -418,6 +415,9 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (* // Start the metrics handlers. go s.sessionStats() + // Initialize Autopilot + s.initAutopilot(config) + // Start the server health checking. go s.autopilot.ServerHealthLoop(s.shutdownCh) diff --git a/agent/consul/server_oss.go b/agent/consul/server_oss.go index 5038b7fd5..dc5d52747 100644 --- a/agent/consul/server_oss.go +++ b/agent/consul/server_oss.go @@ -1,7 +1,5 @@ package consul -import "github.com/hashicorp/consul/agent/consul/autopilot" - func init() { registerEndpoint(func(s *Server) interface{} { return &ACL{s} }) registerEndpoint(func(s *Server) interface{} { return &Catalog{s} }) @@ -14,10 +12,4 @@ func init() { registerEndpoint(func(s *Server) interface{} { return &Session{s} }) registerEndpoint(func(s *Server) interface{} { return &Status{s} }) registerEndpoint(func(s *Server) interface{} { return &Txn{s} }) -} - -func (s *Server) startServerEnterprise(config *Config) { - // Set up autopilot - apDelegate := &AutopilotDelegate{s} - s.autopilot = autopilot.NewAutopilot(s.logger, apDelegate, config.AutopilotInterval, config.ServerHealthInterval) } \ No newline at end of file