mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +00:00
Add graceful shutdown to prometheus server (#1637)
Fixes prometheus server not stopping if there are open connections
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user