From 044c38aa7bcb726ca08cb0eee4039f250cf10950 Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Mon, 18 Dec 2017 16:55:51 -0800 Subject: [PATCH] Move autopilot setup to a separate file --- agent/consul/server.go | 5 ++--- agent/consul/server_oss.go | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/agent/consul/server.go b/agent/consul/server.go index 3792ec45b..de7b737d8 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -294,9 +294,8 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (* shutdownCh: shutdownCh, } - // Set up autopilot - apDelegate := &AutopilotDelegate{s} - s.autopilot = autopilot.NewAutopilot(logger, apDelegate, config.AutopilotInterval, config.ServerHealthInterval) + // 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) diff --git a/agent/consul/server_oss.go b/agent/consul/server_oss.go index 05c02e46c..5038b7fd5 100644 --- a/agent/consul/server_oss.go +++ b/agent/consul/server_oss.go @@ -1,5 +1,7 @@ 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} }) @@ -13,3 +15,9 @@ func init() { 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