From c057fbd4f40562d67db9acd5b2a58b8d9a279d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= <zoltan.pmail@gmail.com> Date: Wed, 21 Aug 2024 16:39:52 +0200 Subject: [PATCH] Close metrics service --- relay/cmd/main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/relay/cmd/main.go b/relay/cmd/main.go index 239976422..2216bb57f 100644 --- a/relay/cmd/main.go +++ b/relay/cmd/main.go @@ -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) {