From be02242ccd2b107767e6a4ea740b8978c00b72cd Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Tue, 25 Jun 2024 12:06:39 +0200 Subject: [PATCH] Fix usage of deprecated startMetricsHttpServer call (#2032) --- fluffy/fluffy.nim | 18 +++++++++++------- fluffy/tools/portalcli.nim | 18 +++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/fluffy/fluffy.nim b/fluffy/fluffy.nim index 83a1bfa44..36d48cd8c 100644 --- a/fluffy/fluffy.nim +++ b/fluffy/fluffy.nim @@ -308,15 +308,19 @@ proc run(config: PortalConf) {.raises: [CatchableError].} = let address = config.metricsAddress port = config.metricsPort - info "Starting metrics HTTP server", url = "http://" & $address & ":" & $port & "/metrics" + + server = MetricsHttpServerRef.new($address, port).valueOr: + error "Could not instantiate metrics HTTP server", url, error + quit QuitFailure + + info "Starting metrics HTTP server", url try: - chronos_httpserver.startMetricsHttpServer($address, port) - except CatchableError as exc: - raise exc - # TODO: Ideally we don't have the Exception here - except Exception as exc: - raiseAssert exc.msg + waitFor server.start() + except MetricsError as exc: + fatal "Could not start metrics HTTP server", + url, error_msg = exc.msg, error_name = exc.name + quit QuitFailure ## Starting the different networks. d.start() diff --git a/fluffy/tools/portalcli.nim b/fluffy/tools/portalcli.nim index 98abee2c6..a62812f3d 100644 --- a/fluffy/tools/portalcli.nim +++ b/fluffy/tools/portalcli.nim @@ -262,15 +262,19 @@ proc run(config: PortalCliConf) = let address = config.metricsAddress port = config.metricsPort - notice "Starting metrics HTTP server", url = "http://" & $address & ":" & $port & "/metrics" + + server = MetricsHttpServerRef.new($address, port).valueOr: + error "Could not instantiate metrics HTTP server", url, error + quit QuitFailure + + info "Starting metrics HTTP server", url try: - chronos_httpserver.startMetricsHttpServer($address, port) - except CatchableError as exc: - raise exc - except Exception as exc: - raiseAssert exc.msg - # TODO fix metrics + waitFor server.start() + except MetricsError as exc: + fatal "Could not start metrics HTTP server", + url, error_msg = exc.msg, error_name = exc.name + quit QuitFailure case config.cmd of ping: