From 035de6ff553a294b988094b42d83f24f96f13ef6 Mon Sep 17 00:00:00 2001 From: Tobi Okedeji Date: Thu, 4 Jul 2024 11:58:14 +0100 Subject: [PATCH] add the go routine for http server under allora node start --- cmd/node/main.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/node/main.go b/cmd/node/main.go index ded30a2..1be542a 100644 --- a/cmd/node/main.go +++ b/cmd/node/main.go @@ -448,15 +448,6 @@ func run() int { } log = log.Level(level) - // Start HTTP server for Prometheus metrics. - http.Handle("/metrics", promhttp.Handler()) - go func() { - log.Info().Msg("Starting metrics server on :2112") - if err := http.ListenAndServe(":2112", nil); err != nil { - log.Error().Err(err).Str("level", cfg.Log.Level).Msg("could not start metric server") - } - }() - // Determine node role. role, err := parseNodeRole(cfg.Role) if err != nil { @@ -672,6 +663,17 @@ func run() int { log.Info().Msg("Allora Node stopped") }() + // Start HTTP server for Prometheus metrics. + http.Handle("/metrics", promhttp.Handler()) + go func() { + log.Info().Str("role", role.String()).Msg("Starting metrics server on :2112") + if err := http.ListenAndServe(":2112", nil); err != nil { + log.Error().Err(err).Msg("could not start metric server") + } + + log.Info().Msg("Allora Node stopped") + }() + // If we're a head node - start the REST API. if role == blockless.HeadNode {