diff --git a/crates/mvr-api/src/lib.rs b/crates/mvr-api/src/lib.rs index c9bcb4d..74e4992 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 - must keep the Service alive or it aborts + let _metrics_service = metrics.run().await?; axum::serve(listener, app) .with_graceful_shutdown(async move { @@ -70,6 +69,8 @@ pub async fn run_server( }) .await?; + // _metrics_service is dropped here, cleaning up the metrics server + Ok(()) }