Move autopilot initializing to oss file

This commit is contained in:
Kyle Havlovitz 2017-12-18 18:02:17 -08:00
parent 044c38aa7b
commit dfc165a47b
No known key found for this signature in database
GPG Key ID: 8A5E6B173056AD6C
3 changed files with 12 additions and 11 deletions

View File

@ -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)
}

View File

@ -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)

View File

@ -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)
}