Close metrics service

This commit is contained in:
Zoltán Papp 2024-08-21 16:39:52 +02:00
parent c1a54756e8
commit c057fbd4f4

View File

@ -11,6 +11,7 @@ import (
"syscall"
"time"
"github.com/hashicorp/go-multierror"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@ -179,11 +180,15 @@ func execute(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
err = srv.Shutdown(ctx)
if err != nil {
return fmt.Errorf("failed to close server: %s", err)
var shutDownErrors error
if err := srv.Shutdown(ctx); err != nil {
shutDownErrors = multierror.Append(shutDownErrors, fmt.Errorf("failed to close server: %s", err))
}
return nil
if err := metricsServer.Close(); err != nil {
shutDownErrors = multierror.Append(shutDownErrors, fmt.Errorf("failed to close metrics server: %v", err))
}
return shutDownErrors
}
func setupTLSCertManager(letsencryptDataDir string, letsencryptDomains ...string) (*tls.Config, error) {