Improve startServer function

- reorder parameters to match other functions
- move context.Background call into function
main
Jan Dittberner 10 months ago
parent f3be6959ab
commit a0a86f1980

@ -65,7 +65,7 @@ func main() {
config, err := services.ConfigureApplication(logger, "IDP", services.DefaultConfig)
if err != nil {
log.Fatalf("error loading configuration: %v", err)
logger.WithError(err).Fatal("error loading configuration")
}
if level := config.String("log.level"); level != "" {
@ -142,7 +142,7 @@ func main() {
handlerChain := tracing(logging(hsts(errorMiddleware(csrfProtect(router)))))
startServer(context.Background(), handlerChain, logger, config)
startServer(logger, config, handlerChain)
}
func configureAdminClient(config *koanf.Koanf) (*client.Runtime, error) {
@ -178,7 +178,7 @@ func configureAdminClient(config *koanf.Koanf) (*client.Runtime, error) {
return clientTransport, nil
}
func startServer(ctx context.Context, handlerChain http.Handler, logger *log.Logger, config *koanf.Koanf) {
func startServer(logger *log.Logger, config *koanf.Koanf, handlerChain http.Handler) {
clientCertificateCAFile := config.MustString("security.client.ca-file")
serverBindAddress := config.String("server.bind_address")
serverName := config.String("server.name")
@ -217,7 +217,7 @@ func startServer(ctx context.Context, handlerChain http.Handler, logger *log.Log
logger.Infoln("Server is shutting down...")
atomic.StoreInt32(&handlers.Healthy, 0)
ctx, cancel := context.WithTimeout(ctx, ShutdownTimeout)
ctx, cancel := context.WithTimeout(context.Background(), ShutdownTimeout)
defer cancel()
server.SetKeepAlivesEnabled(false)

Loading…
Cancel
Save