Skip to content
Snippets Groups Projects
Unverified Commit a56fd32e authored by tmpolaczyk's avatar tmpolaczyk Committed by GitHub
Browse files

Add graceful shutdown to prometheus server (#1637)

Fixes prometheus server not stopping if there are open connections
parent 9e403629
Branches
No related merge requests found
Pipeline #392767 passed with stages
in 51 minutes and 44 seconds
......@@ -111,10 +111,16 @@ async fn init_prometheus_with_listener(
}
});
let server = Server::builder(listener).serve(service);
let (signal, on_exit) = tokio::sync::oneshot::channel::<()>();
let server = Server::builder(listener).serve(service).with_graceful_shutdown(async {
let _ = on_exit.await;
});
let result = server.await.map_err(Into::into);
// Gracefully shutdown server, otherwise the server does not stop if it has open connections
let _ = signal.send(());
result
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment