Change server receiver name.

This commit is contained in:
Ludovic Fernandez 2017-11-24 19:18:03 +01:00 committed by Traefiker
parent f6181ef3e2
commit 011b748a55
4 changed files with 208 additions and 208 deletions

View file

@ -60,7 +60,7 @@ type Provider struct {
DCOSToken string `description:"DCOSToken for DCOS environment, This will override the Authorization header" export:"true"`
MarathonLBCompatibility bool `description:"Add compatibility with marathon-lb labels" export:"true"`
FilterMarathonConstraints bool `description:"Enable use of Marathon constraints in constraint filtering" export:"true"`
TLS *types.ClientTLS `description:"Enable Docker TLS support" export:"true"`
TLS *types.ClientTLS `description:"Enable TLS support" export:"true"`
DialerTimeout flaeg.Duration `description:"Set a non-default connection timeout for Marathon" export:"true"`
KeepAlive flaeg.Duration `description:"Set a non-default TCP Keep Alive time in seconds" export:"true"`
ForceTaskHostname bool `description:"Force to use the task's hostname." export:"true"`

View file

@ -188,34 +188,34 @@ func createRootCACertPool(rootCAs traefikTls.RootCAs) *x509.CertPool {
}
// Start starts the server.
func (server *Server) Start() {
server.startHTTPServers()
server.startLeadership()
server.routinesPool.Go(func(stop chan bool) {
server.listenProviders(stop)
func (s *Server) Start() {
s.startHTTPServers()
s.startLeadership()
s.routinesPool.Go(func(stop chan bool) {
s.listenProviders(stop)
})
server.routinesPool.Go(func(stop chan bool) {
server.listenConfigurations(stop)
s.routinesPool.Go(func(stop chan bool) {
s.listenConfigurations(stop)
})
server.configureProviders()
server.startProviders()
go server.listenSignals()
s.configureProviders()
s.startProviders()
go s.listenSignals()
}
// Wait blocks until server is shutted down.
func (server *Server) Wait() {
<-server.stopChan
func (s *Server) Wait() {
<-s.stopChan
}
// Stop stops the server
func (server *Server) Stop() {
func (s *Server) Stop() {
defer log.Info("Server stopped")
var wg sync.WaitGroup
for sepn, sep := range server.serverEntryPoints {
for sepn, sep := range s.serverEntryPoints {
wg.Add(1)
go func(serverEntryPointName string, serverEntryPoint *serverEntryPoint) {
defer wg.Done()
graceTimeOut := time.Duration(server.globalConfiguration.LifeCycle.GraceTimeOut)
graceTimeOut := time.Duration(s.globalConfiguration.LifeCycle.GraceTimeOut)
ctx, cancel := context.WithTimeout(context.Background(), graceTimeOut)
log.Debugf("Waiting %s seconds before killing connections on entrypoint %s...", graceTimeOut, serverEntryPointName)
if err := serverEntryPoint.httpServer.Shutdown(ctx); err != nil {
@ -227,12 +227,12 @@ func (server *Server) Stop() {
}(sepn, sep)
}
wg.Wait()
server.stopChan <- true
s.stopChan <- true
}
// Close destroys the server
func (server *Server) Close() {
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(server.globalConfiguration.LifeCycle.GraceTimeOut))
func (s *Server) Close() {
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(s.globalConfiguration.LifeCycle.GraceTimeOut))
go func(ctx context.Context) {
<-ctx.Done()
if ctx.Err() == context.Canceled {
@ -243,109 +243,109 @@ func (server *Server) Close() {
}
}(ctx)
stopMetricsClients()
server.stopLeadership()
server.routinesPool.Cleanup()
close(server.configurationChan)
close(server.configurationValidatedChan)
signal.Stop(server.signals)
close(server.signals)
close(server.stopChan)
if server.accessLoggerMiddleware != nil {
if err := server.accessLoggerMiddleware.Close(); err != nil {
s.stopLeadership()
s.routinesPool.Cleanup()
close(s.configurationChan)
close(s.configurationValidatedChan)
signal.Stop(s.signals)
close(s.signals)
close(s.stopChan)
if s.accessLoggerMiddleware != nil {
if err := s.accessLoggerMiddleware.Close(); err != nil {
log.Errorf("Error closing access log file: %s", err)
}
}
cancel()
}
func (server *Server) startLeadership() {
if server.leadership != nil {
server.leadership.Participate(server.routinesPool)
func (s *Server) startLeadership() {
if s.leadership != nil {
s.leadership.Participate(s.routinesPool)
}
}
func (server *Server) stopLeadership() {
if server.leadership != nil {
server.leadership.Stop()
func (s *Server) stopLeadership() {
if s.leadership != nil {
s.leadership.Stop()
}
}
func (server *Server) startHTTPServers() {
server.serverEntryPoints = server.buildEntryPoints(server.globalConfiguration)
func (s *Server) startHTTPServers() {
s.serverEntryPoints = s.buildEntryPoints(s.globalConfiguration)
for newServerEntryPointName, newServerEntryPoint := range server.serverEntryPoints {
serverEntryPoint := server.setupServerEntryPoint(newServerEntryPointName, newServerEntryPoint)
go server.startServer(serverEntryPoint, server.globalConfiguration)
for newServerEntryPointName, newServerEntryPoint := range s.serverEntryPoints {
serverEntryPoint := s.setupServerEntryPoint(newServerEntryPointName, newServerEntryPoint)
go s.startServer(serverEntryPoint, s.globalConfiguration)
}
}
func (server *Server) setupServerEntryPoint(newServerEntryPointName string, newServerEntryPoint *serverEntryPoint) *serverEntryPoint {
func (s *Server) setupServerEntryPoint(newServerEntryPointName string, newServerEntryPoint *serverEntryPoint) *serverEntryPoint {
serverMiddlewares := []negroni.Handler{middlewares.NegroniRecoverHandler()}
serverInternalMiddlewares := []negroni.Handler{middlewares.NegroniRecoverHandler()}
if server.accessLoggerMiddleware != nil {
serverMiddlewares = append(serverMiddlewares, server.accessLoggerMiddleware)
if s.accessLoggerMiddleware != nil {
serverMiddlewares = append(serverMiddlewares, s.accessLoggerMiddleware)
}
if server.metricsRegistry.IsEnabled() {
serverMiddlewares = append(serverMiddlewares, middlewares.NewMetricsWrapper(server.metricsRegistry, newServerEntryPointName))
if s.metricsRegistry.IsEnabled() {
serverMiddlewares = append(serverMiddlewares, middlewares.NewMetricsWrapper(s.metricsRegistry, newServerEntryPointName))
}
if server.globalConfiguration.API != nil {
server.globalConfiguration.API.Stats = thoas_stats.New()
serverMiddlewares = append(serverMiddlewares, server.globalConfiguration.API.Stats)
if server.globalConfiguration.API.Statistics != nil {
server.globalConfiguration.API.StatsRecorder = middlewares.NewStatsRecorder(server.globalConfiguration.API.Statistics.RecentErrors)
serverMiddlewares = append(serverMiddlewares, server.globalConfiguration.API.StatsRecorder)
if s.globalConfiguration.API != nil {
s.globalConfiguration.API.Stats = thoas_stats.New()
serverMiddlewares = append(serverMiddlewares, s.globalConfiguration.API.Stats)
if s.globalConfiguration.API.Statistics != nil {
s.globalConfiguration.API.StatsRecorder = middlewares.NewStatsRecorder(s.globalConfiguration.API.Statistics.RecentErrors)
serverMiddlewares = append(serverMiddlewares, s.globalConfiguration.API.StatsRecorder)
}
}
if server.globalConfiguration.EntryPoints[newServerEntryPointName].Auth != nil {
authMiddleware, err := mauth.NewAuthenticator(server.globalConfiguration.EntryPoints[newServerEntryPointName].Auth)
if s.globalConfiguration.EntryPoints[newServerEntryPointName].Auth != nil {
authMiddleware, err := mauth.NewAuthenticator(s.globalConfiguration.EntryPoints[newServerEntryPointName].Auth)
if err != nil {
log.Fatal("Error starting server: ", err)
}
serverMiddlewares = append(serverMiddlewares, authMiddleware)
serverInternalMiddlewares = append(serverInternalMiddlewares, authMiddleware)
}
if server.globalConfiguration.EntryPoints[newServerEntryPointName].Compress {
if s.globalConfiguration.EntryPoints[newServerEntryPointName].Compress {
serverMiddlewares = append(serverMiddlewares, &middlewares.Compress{})
}
if len(server.globalConfiguration.EntryPoints[newServerEntryPointName].WhitelistSourceRange) > 0 {
ipWhitelistMiddleware, err := middlewares.NewIPWhitelister(server.globalConfiguration.EntryPoints[newServerEntryPointName].WhitelistSourceRange)
if len(s.globalConfiguration.EntryPoints[newServerEntryPointName].WhitelistSourceRange) > 0 {
ipWhitelistMiddleware, err := middlewares.NewIPWhitelister(s.globalConfiguration.EntryPoints[newServerEntryPointName].WhitelistSourceRange)
if err != nil {
log.Fatal("Error starting server: ", err)
}
serverMiddlewares = append(serverMiddlewares, ipWhitelistMiddleware)
serverInternalMiddlewares = append(serverInternalMiddlewares, ipWhitelistMiddleware)
}
newSrv, listener, err := server.prepareServer(newServerEntryPointName, server.globalConfiguration.EntryPoints[newServerEntryPointName], newServerEntryPoint.httpRouter, serverMiddlewares, serverInternalMiddlewares)
newSrv, listener, err := s.prepareServer(newServerEntryPointName, s.globalConfiguration.EntryPoints[newServerEntryPointName], newServerEntryPoint.httpRouter, serverMiddlewares, serverInternalMiddlewares)
if err != nil {
log.Fatal("Error preparing server: ", err)
}
serverEntryPoint := server.serverEntryPoints[newServerEntryPointName]
serverEntryPoint := s.serverEntryPoints[newServerEntryPointName]
serverEntryPoint.httpServer = newSrv
serverEntryPoint.listener = listener
return serverEntryPoint
}
func (server *Server) listenProviders(stop chan bool) {
func (s *Server) listenProviders(stop chan bool) {
for {
select {
case <-stop:
return
case configMsg, ok := <-server.configurationChan:
case configMsg, ok := <-s.configurationChan:
if !ok || configMsg.Configuration == nil {
return
}
server.preLoadConfiguration(configMsg)
s.preLoadConfiguration(configMsg)
}
}
}
func (server *Server) preLoadConfiguration(configMsg types.ConfigMessage) {
func (s *Server) preLoadConfiguration(configMsg types.ConfigMessage) {
providerConfigUpdateMap := map[string]chan types.ConfigMessage{}
providersThrottleDuration := time.Duration(server.globalConfiguration.ProvidersThrottleDuration)
server.defaultConfigurationValues(configMsg.Configuration)
currentConfigurations := server.currentConfigurations.Get().(types.Configurations)
providersThrottleDuration := time.Duration(s.globalConfiguration.ProvidersThrottleDuration)
s.defaultConfigurationValues(configMsg.Configuration)
currentConfigurations := s.currentConfigurations.Get().(types.Configurations)
jsonConf, _ := json.Marshal(configMsg.Configuration)
log.Debugf("Configuration received from provider %s: %s", configMsg.ProviderName, string(jsonConf))
if configMsg.Configuration == nil || configMsg.Configuration.Backends == nil && configMsg.Configuration.Frontends == nil && configMsg.Configuration.TLSConfiguration == nil {
@ -356,8 +356,8 @@ func (server *Server) preLoadConfiguration(configMsg types.ConfigMessage) {
if _, ok := providerConfigUpdateMap[configMsg.ProviderName]; !ok {
providerConfigUpdate := make(chan types.ConfigMessage)
providerConfigUpdateMap[configMsg.ProviderName] = providerConfigUpdate
server.routinesPool.Go(func(stop chan bool) {
throttleProviderConfigReload(providersThrottleDuration, server.configurationValidatedChan, providerConfigUpdate, stop)
s.routinesPool.Go(func(stop chan bool) {
throttleProviderConfigReload(providersThrottleDuration, s.configurationValidatedChan, providerConfigUpdate, stop)
})
}
providerConfigUpdateMap[configMsg.ProviderName] <- configMsg
@ -393,31 +393,31 @@ func throttleProviderConfigReload(throttle time.Duration, publish chan<- types.C
}
}
func (server *Server) defaultConfigurationValues(configuration *types.Configuration) {
func (s *Server) defaultConfigurationValues(configuration *types.Configuration) {
if configuration == nil || configuration.Frontends == nil {
return
}
server.configureFrontends(configuration.Frontends)
server.configureBackends(configuration.Backends)
s.configureFrontends(configuration.Frontends)
s.configureBackends(configuration.Backends)
}
func (server *Server) listenConfigurations(stop chan bool) {
func (s *Server) listenConfigurations(stop chan bool) {
for {
select {
case <-stop:
return
case configMsg, ok := <-server.configurationValidatedChan:
case configMsg, ok := <-s.configurationValidatedChan:
if !ok || configMsg.Configuration == nil {
return
}
server.loadConfiguration(configMsg)
s.loadConfiguration(configMsg)
}
}
}
// loadConfiguration manages dynamically frontends, backends and TLS configurations
func (server *Server) loadConfiguration(configMsg types.ConfigMessage) {
currentConfigurations := server.currentConfigurations.Get().(types.Configurations)
func (s *Server) loadConfiguration(configMsg types.ConfigMessage) {
currentConfigurations := s.currentConfigurations.Get().(types.Configurations)
// Copy configurations to new map so we don't change current if LoadConfig fails
newConfigurations := make(types.Configurations)
@ -426,24 +426,24 @@ func (server *Server) loadConfiguration(configMsg types.ConfigMessage) {
}
newConfigurations[configMsg.ProviderName] = configMsg.Configuration
newServerEntryPoints, err := server.loadConfig(newConfigurations, server.globalConfiguration)
newServerEntryPoints, err := s.loadConfig(newConfigurations, s.globalConfiguration)
if err == nil {
for newServerEntryPointName, newServerEntryPoint := range newServerEntryPoints {
server.serverEntryPoints[newServerEntryPointName].httpRouter.UpdateHandler(newServerEntryPoint.httpRouter.GetHandler())
s.serverEntryPoints[newServerEntryPointName].httpRouter.UpdateHandler(newServerEntryPoint.httpRouter.GetHandler())
if &newServerEntryPoint.certs != nil {
server.serverEntryPoints[newServerEntryPointName].certs.Set(newServerEntryPoint.certs.Get())
s.serverEntryPoints[newServerEntryPointName].certs.Set(newServerEntryPoint.certs.Get())
}
log.Infof("Server configuration reloaded on %s", server.serverEntryPoints[newServerEntryPointName].httpServer.Addr)
log.Infof("Server configuration reloaded on %s", s.serverEntryPoints[newServerEntryPointName].httpServer.Addr)
}
server.currentConfigurations.Set(newConfigurations)
server.postLoadConfiguration()
s.currentConfigurations.Set(newConfigurations)
s.postLoadConfiguration()
} else {
log.Error("Error loading new configuration, aborted ", err)
}
}
// loadHTTPSConfiguration add/delete HTTPS certificate managed dynamically
func (server *Server) loadHTTPSConfiguration(configurations types.Configurations) (map[string]*traefikTls.DomainsCertificates, error) {
func (s *Server) loadHTTPSConfiguration(configurations types.Configurations) (map[string]*traefikTls.DomainsCertificates, error) {
newEPCertificates := make(map[string]*traefikTls.DomainsCertificates)
// Get all certificates
for _, configuration := range configurations {
@ -473,15 +473,15 @@ func (s *serverEntryPoint) getCertificate(clientHello *tls.ClientHelloInfo) (*tl
return nil, nil
}
func (server *Server) postLoadConfiguration() {
if server.globalConfiguration.ACME == nil {
func (s *Server) postLoadConfiguration() {
if s.globalConfiguration.ACME == nil {
return
}
if server.leadership != nil && !server.leadership.IsLeader() {
if s.leadership != nil && !s.leadership.IsLeader() {
return
}
if server.globalConfiguration.ACME.OnHostRule {
currentConfigurations := server.currentConfigurations.Get().(types.Configurations)
if s.globalConfiguration.ACME.OnHostRule {
currentConfigurations := s.currentConfigurations.Get().(types.Configurations)
for _, config := range currentConfigurations {
for _, frontend := range config.Frontends {
@ -489,7 +489,7 @@ func (server *Server) postLoadConfiguration() {
// and is configured with ACME
ACMEEnabled := false
for _, entryPoint := range frontend.EntryPoints {
if server.globalConfiguration.ACME.EntryPoint == entryPoint && server.globalConfiguration.EntryPoints[entryPoint].TLS != nil {
if s.globalConfiguration.ACME.EntryPoint == entryPoint && s.globalConfiguration.EntryPoints[entryPoint].TLS != nil {
ACMEEnabled = true
break
}
@ -502,7 +502,7 @@ func (server *Server) postLoadConfiguration() {
if err != nil {
log.Errorf("Error parsing domains: %v", err)
} else {
server.globalConfiguration.ACME.LoadCertificateForDomains(domains)
s.globalConfiguration.ACME.LoadCertificateForDomains(domains)
}
}
}
@ -511,65 +511,65 @@ func (server *Server) postLoadConfiguration() {
}
}
func (server *Server) configureProviders() {
func (s *Server) configureProviders() {
// configure providers
if server.globalConfiguration.Docker != nil {
server.providers = append(server.providers, server.globalConfiguration.Docker)
if s.globalConfiguration.Docker != nil {
s.providers = append(s.providers, s.globalConfiguration.Docker)
}
if server.globalConfiguration.Marathon != nil {
server.providers = append(server.providers, server.globalConfiguration.Marathon)
if s.globalConfiguration.Marathon != nil {
s.providers = append(s.providers, s.globalConfiguration.Marathon)
}
if server.globalConfiguration.File != nil {
server.providers = append(server.providers, server.globalConfiguration.File)
if s.globalConfiguration.File != nil {
s.providers = append(s.providers, s.globalConfiguration.File)
}
if server.globalConfiguration.Rest != nil {
server.providers = append(server.providers, server.globalConfiguration.Rest)
server.globalConfiguration.Rest.CurrentConfigurations = &server.currentConfigurations
if s.globalConfiguration.Rest != nil {
s.providers = append(s.providers, s.globalConfiguration.Rest)
s.globalConfiguration.Rest.CurrentConfigurations = &s.currentConfigurations
}
if server.globalConfiguration.Consul != nil {
server.providers = append(server.providers, server.globalConfiguration.Consul)
if s.globalConfiguration.Consul != nil {
s.providers = append(s.providers, s.globalConfiguration.Consul)
}
if server.globalConfiguration.ConsulCatalog != nil {
server.providers = append(server.providers, server.globalConfiguration.ConsulCatalog)
if s.globalConfiguration.ConsulCatalog != nil {
s.providers = append(s.providers, s.globalConfiguration.ConsulCatalog)
}
if server.globalConfiguration.Etcd != nil {
server.providers = append(server.providers, server.globalConfiguration.Etcd)
if s.globalConfiguration.Etcd != nil {
s.providers = append(s.providers, s.globalConfiguration.Etcd)
}
if server.globalConfiguration.Zookeeper != nil {
server.providers = append(server.providers, server.globalConfiguration.Zookeeper)
if s.globalConfiguration.Zookeeper != nil {
s.providers = append(s.providers, s.globalConfiguration.Zookeeper)
}
if server.globalConfiguration.Boltdb != nil {
server.providers = append(server.providers, server.globalConfiguration.Boltdb)
if s.globalConfiguration.Boltdb != nil {
s.providers = append(s.providers, s.globalConfiguration.Boltdb)
}
if server.globalConfiguration.Kubernetes != nil {
server.providers = append(server.providers, server.globalConfiguration.Kubernetes)
if s.globalConfiguration.Kubernetes != nil {
s.providers = append(s.providers, s.globalConfiguration.Kubernetes)
}
if server.globalConfiguration.Mesos != nil {
server.providers = append(server.providers, server.globalConfiguration.Mesos)
if s.globalConfiguration.Mesos != nil {
s.providers = append(s.providers, s.globalConfiguration.Mesos)
}
if server.globalConfiguration.Eureka != nil {
server.providers = append(server.providers, server.globalConfiguration.Eureka)
if s.globalConfiguration.Eureka != nil {
s.providers = append(s.providers, s.globalConfiguration.Eureka)
}
if server.globalConfiguration.ECS != nil {
server.providers = append(server.providers, server.globalConfiguration.ECS)
if s.globalConfiguration.ECS != nil {
s.providers = append(s.providers, s.globalConfiguration.ECS)
}
if server.globalConfiguration.Rancher != nil {
server.providers = append(server.providers, server.globalConfiguration.Rancher)
if s.globalConfiguration.Rancher != nil {
s.providers = append(s.providers, s.globalConfiguration.Rancher)
}
if server.globalConfiguration.DynamoDB != nil {
server.providers = append(server.providers, server.globalConfiguration.DynamoDB)
if s.globalConfiguration.DynamoDB != nil {
s.providers = append(s.providers, s.globalConfiguration.DynamoDB)
}
}
func (server *Server) startProviders() {
func (s *Server) startProviders() {
// start providers
for _, p := range server.providers {
for _, p := range s.providers {
providerType := reflect.TypeOf(p)
jsonConf, _ := json.Marshal(p)
log.Infof("Starting provider %v %s", providerType, jsonConf)
currentProvider := p
safe.Go(func() {
err := currentProvider.Provide(server.configurationChan, server.routinesPool, server.globalConfiguration.Constraints)
err := currentProvider.Provide(s.configurationChan, s.routinesPool, s.globalConfiguration.Constraints)
if err != nil {
log.Errorf("Error starting provider %v: %s", providerType, err)
}
@ -610,7 +610,7 @@ func createClientTLSConfig(entryPointName string, tlsOption *traefikTls.TLS) (*t
}
// creates a TLS config that allows terminating HTTPS for multiple domains using SNI
func (server *Server) createTLSConfig(entryPointName string, tlsOption *traefikTls.TLS, router *middlewares.HandlerSwitcher) (*tls.Config, error) {
func (s *Server) createTLSConfig(entryPointName string, tlsOption *traefikTls.TLS, router *middlewares.HandlerSwitcher) (*tls.Config, error) {
if tlsOption == nil {
return nil, nil
}
@ -625,7 +625,7 @@ func (server *Server) createTLSConfig(entryPointName string, tlsOption *traefikT
} else {
*epDomainsCertificatesTmp = make(map[string]*tls.Certificate)
}
server.serverEntryPoints[entryPointName].certs.Set(epDomainsCertificatesTmp)
s.serverEntryPoints[entryPointName].certs.Set(epDomainsCertificatesTmp)
// ensure http2 enabled
config.NextProtos = []string{"h2", "http/1.1"}
@ -654,9 +654,9 @@ func (server *Server) createTLSConfig(entryPointName string, tlsOption *traefikT
}
}
if server.globalConfiguration.ACME != nil {
if _, ok := server.serverEntryPoints[server.globalConfiguration.ACME.EntryPoint]; ok {
if entryPointName == server.globalConfiguration.ACME.EntryPoint {
if s.globalConfiguration.ACME != nil {
if _, ok := s.serverEntryPoints[s.globalConfiguration.ACME.EntryPoint]; ok {
if entryPointName == s.globalConfiguration.ACME.EntryPoint {
checkOnDemandDomain := func(domain string) bool {
routeMatch := &mux.RouteMatch{}
router := router.GetHandler()
@ -666,23 +666,23 @@ func (server *Server) createTLSConfig(entryPointName string, tlsOption *traefikT
}
return false
}
if server.leadership == nil {
err := server.globalConfiguration.ACME.CreateLocalConfig(config, &server.serverEntryPoints[entryPointName].certs, checkOnDemandDomain)
if s.leadership == nil {
err := s.globalConfiguration.ACME.CreateLocalConfig(config, &s.serverEntryPoints[entryPointName].certs, checkOnDemandDomain)
if err != nil {
return nil, err
}
} else {
err := server.globalConfiguration.ACME.CreateClusterConfig(server.leadership, config, &server.serverEntryPoints[entryPointName].certs, checkOnDemandDomain)
err := s.globalConfiguration.ACME.CreateClusterConfig(s.leadership, config, &s.serverEntryPoints[entryPointName].certs, checkOnDemandDomain)
if err != nil {
return nil, err
}
}
}
} else {
return nil, errors.New("Unknown entrypoint " + server.globalConfiguration.ACME.EntryPoint + " for ACME configuration")
return nil, errors.New("Unknown entrypoint " + s.globalConfiguration.ACME.EntryPoint + " for ACME configuration")
}
} else {
config.GetCertificate = server.serverEntryPoints[entryPointName].getCertificate
config.GetCertificate = s.serverEntryPoints[entryPointName].getCertificate
}
if len(config.Certificates) == 0 {
return nil, errors.New("No certificates found for TLS entrypoint " + entryPointName)
@ -691,15 +691,15 @@ func (server *Server) createTLSConfig(entryPointName string, tlsOption *traefikT
// in each certificate and populates the config.NameToCertificate map.
config.BuildNameToCertificate()
//Set the minimum TLS version if set in the config TOML
if minConst, exists := traefikTls.MinVersion[server.globalConfiguration.EntryPoints[entryPointName].TLS.MinVersion]; exists {
if minConst, exists := traefikTls.MinVersion[s.globalConfiguration.EntryPoints[entryPointName].TLS.MinVersion]; exists {
config.PreferServerCipherSuites = true
config.MinVersion = minConst
}
//Set the list of CipherSuites if set in the config TOML
if server.globalConfiguration.EntryPoints[entryPointName].TLS.CipherSuites != nil {
if s.globalConfiguration.EntryPoints[entryPointName].TLS.CipherSuites != nil {
//if our list of CipherSuites is defined in the entrypoint config, we can re-initilize the suites list as empty
config.CipherSuites = make([]uint16, 0)
for _, cipher := range server.globalConfiguration.EntryPoints[entryPointName].TLS.CipherSuites {
for _, cipher := range s.globalConfiguration.EntryPoints[entryPointName].TLS.CipherSuites {
if cipherConst, exists := traefikTls.CipherSuites[cipher]; exists {
config.CipherSuites = append(config.CipherSuites, cipherConst)
} else {
@ -711,7 +711,7 @@ func (server *Server) createTLSConfig(entryPointName string, tlsOption *traefikT
return config, nil
}
func (server *Server) startServer(serverEntryPoint *serverEntryPoint, globalConfiguration configuration.GlobalConfiguration) {
func (s *Server) startServer(serverEntryPoint *serverEntryPoint, globalConfiguration configuration.GlobalConfiguration) {
log.Infof("Starting server on %s", serverEntryPoint.httpServer.Addr)
var err error
if serverEntryPoint.httpServer.TLSConfig != nil {
@ -724,28 +724,28 @@ func (server *Server) startServer(serverEntryPoint *serverEntryPoint, globalConf
}
}
func (server *Server) addInternalRoutes(entryPointName string, router *mux.Router) {
if server.globalConfiguration.Metrics != nil && server.globalConfiguration.Metrics.Prometheus != nil && server.globalConfiguration.Metrics.Prometheus.EntryPoint == entryPointName {
func (s *Server) addInternalRoutes(entryPointName string, router *mux.Router) {
if s.globalConfiguration.Metrics != nil && s.globalConfiguration.Metrics.Prometheus != nil && s.globalConfiguration.Metrics.Prometheus.EntryPoint == entryPointName {
metrics.PrometheusHandler{}.AddRoutes(router)
}
if server.globalConfiguration.Rest != nil && server.globalConfiguration.Rest.EntryPoint == entryPointName {
server.globalConfiguration.Rest.AddRoutes(router)
if s.globalConfiguration.Rest != nil && s.globalConfiguration.Rest.EntryPoint == entryPointName {
s.globalConfiguration.Rest.AddRoutes(router)
}
if server.globalConfiguration.API != nil && server.globalConfiguration.API.EntryPoint == entryPointName {
server.globalConfiguration.API.AddRoutes(router)
if s.globalConfiguration.API != nil && s.globalConfiguration.API.EntryPoint == entryPointName {
s.globalConfiguration.API.AddRoutes(router)
}
}
func (server *Server) addInternalPublicRoutes(entryPointName string, router *mux.Router) {
if server.globalConfiguration.Ping != nil && server.globalConfiguration.Ping.EntryPoint != "" && server.globalConfiguration.Ping.EntryPoint == entryPointName {
server.globalConfiguration.Ping.AddRoutes(router)
func (s *Server) addInternalPublicRoutes(entryPointName string, router *mux.Router) {
if s.globalConfiguration.Ping != nil && s.globalConfiguration.Ping.EntryPoint != "" && s.globalConfiguration.Ping.EntryPoint == entryPointName {
s.globalConfiguration.Ping.AddRoutes(router)
}
}
func (server *Server) prepareServer(entryPointName string, entryPoint *configuration.EntryPoint, router *middlewares.HandlerSwitcher, middlewares []negroni.Handler, internalMiddlewares []negroni.Handler) (*http.Server, net.Listener, error) {
readTimeout, writeTimeout, idleTimeout := buildServerTimeouts(server.globalConfiguration)
func (s *Server) prepareServer(entryPointName string, entryPoint *configuration.EntryPoint, router *middlewares.HandlerSwitcher, middlewares []negroni.Handler, internalMiddlewares []negroni.Handler) (*http.Server, net.Listener, error) {
readTimeout, writeTimeout, idleTimeout := buildServerTimeouts(s.globalConfiguration)
log.Infof("Preparing server %s %+v with readTimeout=%s writeTimeout=%s idleTimeout=%s", entryPointName, entryPoint, readTimeout, writeTimeout, idleTimeout)
// middlewares
@ -756,14 +756,14 @@ func (server *Server) prepareServer(entryPointName string, entryPoint *configura
n.UseHandler(router)
path := "/"
if server.globalConfiguration.Web != nil && server.globalConfiguration.Web.Path != "" {
path = server.globalConfiguration.Web.Path
if s.globalConfiguration.Web != nil && s.globalConfiguration.Web.Path != "" {
path = s.globalConfiguration.Web.Path
}
internalMuxRouter := server.buildInternalRouter(entryPointName, path, internalMiddlewares)
internalMuxRouter := s.buildInternalRouter(entryPointName, path, internalMiddlewares)
internalMuxRouter.NotFoundHandler = n
tlsConfig, err := server.createTLSConfig(entryPointName, entryPoint.TLS, router)
tlsConfig, err := s.createTLSConfig(entryPointName, entryPoint.TLS, router)
if err != nil {
log.Errorf("Error creating TLS config: %s", err)
return nil, nil, err
@ -806,7 +806,7 @@ func (server *Server) prepareServer(entryPointName string, entryPoint *configura
nil
}
func (server *Server) buildInternalRouter(entryPointName, path string, internalMiddlewares []negroni.Handler) *mux.Router {
func (s *Server) buildInternalRouter(entryPointName, path string, internalMiddlewares []negroni.Handler) *mux.Router {
internalMuxRouter := mux.NewRouter()
internalMuxRouter.StrictSlash(true)
internalMuxRouter.SkipClean(true)
@ -815,10 +815,10 @@ func (server *Server) buildInternalRouter(entryPointName, path string, internalM
internalMuxSubrouter.StrictSlash(true)
internalMuxSubrouter.SkipClean(true)
server.addInternalRoutes(entryPointName, internalMuxSubrouter)
s.addInternalRoutes(entryPointName, internalMuxSubrouter)
internalMuxRouter.Walk(wrapRoute(internalMiddlewares))
server.addInternalPublicRoutes(entryPointName, internalMuxSubrouter)
s.addInternalPublicRoutes(entryPointName, internalMuxSubrouter)
return internalMuxRouter
}
@ -852,10 +852,10 @@ func buildServerTimeouts(globalConfig configuration.GlobalConfiguration) (readTi
return readTimeout, writeTimeout, idleTimeout
}
func (server *Server) buildEntryPoints(globalConfiguration configuration.GlobalConfiguration) map[string]*serverEntryPoint {
func (s *Server) buildEntryPoints(globalConfiguration configuration.GlobalConfiguration) map[string]*serverEntryPoint {
serverEntryPoints := make(map[string]*serverEntryPoint)
for entryPointName := range globalConfiguration.EntryPoints {
router := server.buildDefaultHTTPRouter()
router := s.buildDefaultHTTPRouter()
serverEntryPoints[entryPointName] = &serverEntryPoint{
httpRouter: middlewares.NewHandlerSwitcher(router),
}
@ -865,7 +865,7 @@ func (server *Server) buildEntryPoints(globalConfiguration configuration.GlobalC
// getRoundTripper will either use server.defaultForwardingRoundTripper or create a new one
// given a custom TLS configuration is passed and the passTLSCert option is set to true.
func (server *Server) getRoundTripper(entryPointName string, globalConfiguration configuration.GlobalConfiguration, passTLSCert bool, tls *traefikTls.TLS) (http.RoundTripper, error) {
func (s *Server) getRoundTripper(entryPointName string, globalConfiguration configuration.GlobalConfiguration, passTLSCert bool, tls *traefikTls.TLS) (http.RoundTripper, error) {
if passTLSCert {
tlsConfig, err := createClientTLSConfig(entryPointName, tls)
if err != nil {
@ -878,13 +878,13 @@ func (server *Server) getRoundTripper(entryPointName string, globalConfiguration
return transport, nil
}
return server.defaultForwardingRoundTripper, nil
return s.defaultForwardingRoundTripper, nil
}
// LoadConfig returns a new gorilla.mux Route from the specified global configuration and the dynamic
// provider configurations.
func (server *Server) loadConfig(configurations types.Configurations, globalConfiguration configuration.GlobalConfiguration) (map[string]*serverEntryPoint, error) {
serverEntryPoints := server.buildEntryPoints(globalConfiguration)
func (s *Server) loadConfig(configurations types.Configurations, globalConfiguration configuration.GlobalConfiguration) (map[string]*serverEntryPoint, error) {
serverEntryPoints := s.buildEntryPoints(globalConfiguration)
redirectHandlers := make(map[string]negroni.Handler)
backends := map[string]http.Handler{}
backendsHealthCheck := map[string]*healthcheck.BackendHealthCheck{}
@ -928,12 +928,12 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
if entryPoint.Redirect != nil {
if redirectHandlers[entryPointName] != nil {
n.Use(redirectHandlers[entryPointName])
} else if handler, err := server.loadEntryPointConfig(entryPointName, entryPoint); err != nil {
} else if handler, err := s.loadEntryPointConfig(entryPointName, entryPoint); err != nil {
log.Errorf("Error loading entrypoint configuration for frontend %s: %v", frontendName, err)
log.Errorf("Skipping frontend %s...", frontendName)
continue frontend
} else {
if server.accessLoggerMiddleware != nil {
if s.accessLoggerMiddleware != nil {
saveFrontend := accesslog.NewSaveNegroniFrontend(handler, frontendName)
n.Use(saveFrontend)
redirectHandlers[entryPointName] = saveFrontend
@ -946,7 +946,7 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
if backends[entryPointName+frontend.Backend] == nil {
log.Debugf("Creating backend %s", frontend.Backend)
roundTripper, err := server.getRoundTripper(entryPointName, globalConfiguration, frontend.PassTLSCert, entryPoint.TLS)
roundTripper, err := s.getRoundTripper(entryPointName, globalConfiguration, frontend.PassTLSCert, entryPoint.TLS)
if err != nil {
log.Errorf("Failed to create RoundTripper for frontend %s: %v", frontendName, err)
log.Errorf("Skipping frontend %s...", frontendName)
@ -984,7 +984,7 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
var rr *roundrobin.RoundRobin
var saveFrontend http.Handler
if server.accessLoggerMiddleware != nil {
if s.accessLoggerMiddleware != nil {
saveBackend := accesslog.NewSaveBackend(fwd, frontend.Backend)
saveFrontend = accesslog.NewSaveFrontend(saveBackend, frontendName)
rr, _ = roundrobin.New(saveFrontend)
@ -1029,7 +1029,7 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
hcOpts := parseHealthCheckOptions(rebalancer, frontend.Backend, config.Backends[frontend.Backend].HealthCheck, globalConfiguration.HealthCheck)
if hcOpts != nil {
log.Debugf("Setting up backend health check %s", *hcOpts)
hcOpts.Transport = server.defaultForwardingRoundTripper
hcOpts.Transport = s.defaultForwardingRoundTripper
backendsHealthCheck[entryPointName+frontend.Backend] = healthcheck.NewBackendHealthCheck(*hcOpts)
}
lb = middlewares.NewEmptyBackendHandler(rebalancer, lb)
@ -1037,7 +1037,7 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
log.Debugf("Creating load-balancer wrr")
if sticky != nil {
log.Debugf("Sticky session with cookie %v", cookieName)
if server.accessLoggerMiddleware != nil {
if s.accessLoggerMiddleware != nil {
rr, _ = roundrobin.New(saveFrontend, roundrobin.EnableStickySession(sticky))
} else {
rr, _ = roundrobin.New(fwd, roundrobin.EnableStickySession(sticky))
@ -1051,7 +1051,7 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
hcOpts := parseHealthCheckOptions(rr, frontend.Backend, config.Backends[frontend.Backend].HealthCheck, globalConfiguration.HealthCheck)
if hcOpts != nil {
log.Debugf("Setting up backend health check %s", *hcOpts)
hcOpts.Transport = server.defaultForwardingRoundTripper
hcOpts.Transport = s.defaultForwardingRoundTripper
backendsHealthCheck[entryPointName+frontend.Backend] = healthcheck.NewBackendHealthCheck(*hcOpts)
}
lb = middlewares.NewEmptyBackendHandler(rr, lb)
@ -1073,7 +1073,7 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
}
if frontend.RateLimit != nil && len(frontend.RateLimit.RateSet) > 0 {
lb, err = server.buildRateLimiter(lb, frontend.RateLimit)
lb, err = s.buildRateLimiter(lb, frontend.RateLimit)
if err != nil {
log.Errorf("Error creating rate limiter: %v", err)
log.Errorf("Skipping frontend %s...", frontendName)
@ -1100,11 +1100,11 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
if globalConfiguration.Retry != nil {
countServers := len(config.Backends[frontend.Backend].Servers)
lb = server.buildRetryMiddleware(lb, globalConfiguration, countServers, frontend.Backend)
lb = s.buildRetryMiddleware(lb, globalConfiguration, countServers, frontend.Backend)
}
if server.metricsRegistry.IsEnabled() {
n.Use(middlewares.NewMetricsWrapper(server.metricsRegistry, frontend.Backend))
if s.metricsRegistry.IsEnabled() {
n.Use(middlewares.NewMetricsWrapper(s.metricsRegistry, frontend.Backend))
}
ipWhitelistMiddleware, err := configureIPWhitelistMiddleware(frontend.WhitelistSourceRange)
@ -1117,11 +1117,11 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
if len(frontend.Redirect) > 0 {
proto := "http"
if server.globalConfiguration.EntryPoints[frontend.Redirect].TLS != nil {
if s.globalConfiguration.EntryPoints[frontend.Redirect].TLS != nil {
proto = "https"
}
regex, replacement, err := server.buildRedirect(proto, entryPoint)
regex, replacement, err := s.buildRedirect(proto, entryPoint)
rewrite, err := middlewares.NewRewrite(regex, replacement, true)
if err != nil {
log.Fatalf("Error creating Frontend Redirect: %v", err)
@ -1177,7 +1177,7 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
if frontend.Priority > 0 {
newServerRoute.route.Priority(frontend.Priority)
}
server.wireFrontendBackend(newServerRoute, backends[entryPointName+frontend.Backend])
s.wireFrontendBackend(newServerRoute, backends[entryPointName+frontend.Backend])
err := newServerRoute.route.GetError()
if err != nil {
@ -1186,10 +1186,10 @@ func (server *Server) loadConfig(configurations types.Configurations, globalConf
}
}
}
healthcheck.GetHealthCheck().SetBackendsConfiguration(server.routinesPool.Ctx(), backendsHealthCheck)
healthcheck.GetHealthCheck().SetBackendsConfiguration(s.routinesPool.Ctx(), backendsHealthCheck)
// Get new certificates list sorted per entrypoints
// Update certificates
entryPointsCertificates, err := server.loadHTTPSConfiguration(configurations)
entryPointsCertificates, err := s.loadHTTPSConfiguration(configurations)
//sort routes and update certificates
for serverEntryPointName, serverEntryPoint := range serverEntryPoints {
serverEntryPoint.httpRouter.GetHandler().SortRoutes()
@ -1233,7 +1233,7 @@ func configureIPWhitelistMiddleware(whitelistSourceRanges []string) (negroni.Han
return nil, nil
}
func (server *Server) wireFrontendBackend(serverRoute *serverRoute, handler http.Handler) {
func (s *Server) wireFrontendBackend(serverRoute *serverRoute, handler http.Handler) {
// path replace - This needs to always be the very last on the handler chain (first in the order in this function)
// -- Replacing Path should happen at the very end of the Modifier chain, after all the Matcher+Modifiers ran
if len(serverRoute.replacePath) > 0 {
@ -1277,16 +1277,16 @@ func (server *Server) wireFrontendBackend(serverRoute *serverRoute, handler http
serverRoute.route.Handler(handler)
}
func (server *Server) loadEntryPointConfig(entryPointName string, entryPoint *configuration.EntryPoint) (negroni.Handler, error) {
func (s *Server) loadEntryPointConfig(entryPointName string, entryPoint *configuration.EntryPoint) (negroni.Handler, error) {
regex := entryPoint.Redirect.Regex
replacement := entryPoint.Redirect.Replacement
var err error
if len(entryPoint.Redirect.EntryPoint) > 0 {
var protocol = "http"
if server.globalConfiguration.EntryPoints[entryPoint.Redirect.EntryPoint].TLS != nil {
if s.globalConfiguration.EntryPoints[entryPoint.Redirect.EntryPoint].TLS != nil {
protocol = "https"
}
regex, replacement, err = server.buildRedirect(protocol, entryPoint)
regex, replacement, err = s.buildRedirect(protocol, entryPoint)
}
rewrite, err := middlewares.NewRewrite(regex, replacement, true)
if err != nil {
@ -1297,21 +1297,21 @@ func (server *Server) loadEntryPointConfig(entryPointName string, entryPoint *co
return rewrite, nil
}
func (server *Server) buildRedirect(protocol string, entryPoint *configuration.EntryPoint) (string, string, error) {
func (s *Server) buildRedirect(protocol string, entryPoint *configuration.EntryPoint) (string, string, error) {
regex := `^(?:https?:\/\/)?([\w\._-]+)(?::\d+)?(.*)$`
if server.globalConfiguration.EntryPoints[entryPoint.Redirect.EntryPoint] == nil {
if s.globalConfiguration.EntryPoints[entryPoint.Redirect.EntryPoint] == nil {
return "", "", fmt.Errorf("unknown target entrypoint %q", entryPoint.Redirect.EntryPoint)
}
r, _ := regexp.Compile(`(:\d+)`)
match := r.FindStringSubmatch(server.globalConfiguration.EntryPoints[entryPoint.Redirect.EntryPoint].Address)
match := r.FindStringSubmatch(s.globalConfiguration.EntryPoints[entryPoint.Redirect.EntryPoint].Address)
if len(match) == 0 {
return "", "", fmt.Errorf("bad Address format %q", server.globalConfiguration.EntryPoints[entryPoint.Redirect.EntryPoint].Address)
return "", "", fmt.Errorf("bad Address format %q", s.globalConfiguration.EntryPoints[entryPoint.Redirect.EntryPoint].Address)
}
replacement := protocol + "://$1" + match[0] + "$2"
return regex, replacement, nil
}
func (server *Server) buildDefaultHTTPRouter() *mux.Router {
func (s *Server) buildDefaultHTTPRouter() *mux.Router {
router := mux.NewRouter()
router.NotFoundHandler = http.HandlerFunc(notFoundHandler)
router.StrictSlash(true)
@ -1365,11 +1365,11 @@ func sortedFrontendNamesForConfig(configuration *types.Configuration) []string {
return keys
}
func (server *Server) configureFrontends(frontends map[string]*types.Frontend) {
func (s *Server) configureFrontends(frontends map[string]*types.Frontend) {
for _, frontend := range frontends {
// default endpoints if not defined in frontends
if len(frontend.EntryPoints) == 0 {
frontend.EntryPoints = server.globalConfiguration.DefaultEntryPoints
frontend.EntryPoints = s.globalConfiguration.DefaultEntryPoints
}
}
}
@ -1411,7 +1411,7 @@ func (*Server) configureBackends(backends map[string]*types.Backend) {
}
}
func (server *Server) registerMetricClients(metricsConfig *types.Metrics) {
func (s *Server) registerMetricClients(metricsConfig *types.Metrics) {
registries := []metrics.Registry{}
if metricsConfig.Prometheus != nil {
@ -1432,7 +1432,7 @@ func (server *Server) registerMetricClients(metricsConfig *types.Metrics) {
}
if len(registries) > 0 {
server.metricsRegistry = metrics.NewMultiRegistry(registries)
s.metricsRegistry = metrics.NewMultiRegistry(registries)
}
}
@ -1442,7 +1442,7 @@ func stopMetricsClients() {
metrics.StopInfluxDB()
}
func (server *Server) buildRateLimiter(handler http.Handler, rlConfig *types.RateLimit) (http.Handler, error) {
func (s *Server) buildRateLimiter(handler http.Handler, rlConfig *types.RateLimit) (http.Handler, error) {
extractFunc, err := utils.NewExtractor(rlConfig.ExtractorFunc)
if err != nil {
return nil, err
@ -1457,12 +1457,12 @@ func (server *Server) buildRateLimiter(handler http.Handler, rlConfig *types.Rat
return ratelimit.New(handler, extractFunc, rateSet)
}
func (server *Server) buildRetryMiddleware(handler http.Handler, globalConfig configuration.GlobalConfiguration, countServers int, backendName string) http.Handler {
func (s *Server) buildRetryMiddleware(handler http.Handler, globalConfig configuration.GlobalConfiguration, countServers int, backendName string) http.Handler {
retryListeners := middlewares.RetryListeners{}
if server.metricsRegistry.IsEnabled() {
retryListeners = append(retryListeners, middlewares.NewMetricsRetryListener(server.metricsRegistry, backendName))
if s.metricsRegistry.IsEnabled() {
retryListeners = append(retryListeners, middlewares.NewMetricsRetryListener(s.metricsRegistry, backendName))
}
if server.accessLoggerMiddleware != nil {
if s.accessLoggerMiddleware != nil {
retryListeners = append(retryListeners, &accesslog.SaveRetries{})
}

View file

@ -10,19 +10,19 @@ import (
"github.com/containous/traefik/log"
)
func (server *Server) configureSignals() {
signal.Notify(server.signals, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1)
func (s *Server) configureSignals() {
signal.Notify(s.signals, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1)
}
func (server *Server) listenSignals() {
func (s *Server) listenSignals() {
for {
sig := <-server.signals
sig := <-s.signals
switch sig {
case syscall.SIGUSR1:
log.Infof("Closing and re-opening log files for rotation: %+v", sig)
if server.accessLoggerMiddleware != nil {
if err := server.accessLoggerMiddleware.Rotate(); err != nil {
if s.accessLoggerMiddleware != nil {
if err := s.accessLoggerMiddleware.Rotate(); err != nil {
log.Errorf("Error rotating access log: %s", err)
}
}
@ -32,13 +32,13 @@ func (server *Server) listenSignals() {
}
default:
log.Infof("I have to go... %+v", sig)
reqAcceptGraceTimeOut := time.Duration(server.globalConfiguration.LifeCycle.RequestAcceptGraceTimeout)
reqAcceptGraceTimeOut := time.Duration(s.globalConfiguration.LifeCycle.RequestAcceptGraceTimeout)
if reqAcceptGraceTimeOut > 0 {
log.Infof("Waiting %s for incoming requests to cease", reqAcceptGraceTimeOut)
time.Sleep(reqAcceptGraceTimeOut)
}
log.Info("Stopping server gracefully")
server.Stop()
s.Stop()
}
}
}

View file

@ -9,18 +9,18 @@ import (
"github.com/containous/traefik/log"
)
func (server *Server) configureSignals() {
signal.Notify(server.signals, syscall.SIGINT, syscall.SIGTERM)
func (s *Server) configureSignals() {
signal.Notify(s.signals, syscall.SIGINT, syscall.SIGTERM)
}
func (server *Server) listenSignals() {
func (s *Server) listenSignals() {
for {
sig := <-server.signals
sig := <-s.signals
switch sig {
default:
log.Infof("I have to go... %+v", sig)
log.Info("Stopping server")
server.Stop()
s.Stop()
}
}
}