From b8c808173e365d6280502b108086793c368fb00b Mon Sep 17 00:00:00 2001 From: Rush Soni Date: Mon, 26 Jan 2026 19:54:10 +0000 Subject: [PATCH 1/2] [metrics] fix failling metrics server for api --- crates/mvr-api/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/mvr-api/src/lib.rs b/crates/mvr-api/src/lib.rs index c9bcb4d..1d373b3 100644 --- a/crates/mvr-api/src/lib.rs +++ b/crates/mvr-api/src/lib.rs @@ -60,9 +60,8 @@ pub async fn run_server( println!("🚀 Server started successfully on port {}", api_port); - let _handle = tokio::spawn(async move { - let _ = metrics.run().await; - }); + // Start the metrics service and keep the handle alive + let h_metrics = metrics.run().await?; axum::serve(listener, app) .with_graceful_shutdown(async move { @@ -70,6 +69,9 @@ pub async fn run_server( }) .await?; + // Await metrics shutdown after API server stops + let _ = h_metrics.await; + Ok(()) } From d3de0ea2baa611ba846f66874f32a5e9785af685 Mon Sep 17 00:00:00 2001 From: Rush Soni Date: Mon, 26 Jan 2026 20:00:26 +0000 Subject: [PATCH 2/2] [metrics] fix failling metrics server for api --- crates/mvr-api/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/mvr-api/src/lib.rs b/crates/mvr-api/src/lib.rs index 1d373b3..74e4992 100644 --- a/crates/mvr-api/src/lib.rs +++ b/crates/mvr-api/src/lib.rs @@ -60,8 +60,8 @@ pub async fn run_server( println!("🚀 Server started successfully on port {}", api_port); - // Start the metrics service and keep the handle alive - let h_metrics = metrics.run().await?; + // Start the metrics service - must keep the Service alive or it aborts + let _metrics_service = metrics.run().await?; axum::serve(listener, app) .with_graceful_shutdown(async move { @@ -69,8 +69,7 @@ pub async fn run_server( }) .await?; - // Await metrics shutdown after API server stops - let _ = h_metrics.await; + // _metrics_service is dropped here, cleaning up the metrics server Ok(()) }