swarm-logs-auth, swarm-metrics-auth, swarm-authelia-bridge, swarm-controller: drain http on sigterm
This commit is contained in:
parent
39c29b64e3
commit
a089da25a5
1 changed files with 198 additions and 19 deletions
|
|
@ -282,6 +282,7 @@ async fn handle(State(responder): State<Arc<Responder<Store>>>, headers: HeaderM
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let stop = swarm_secret_client::shutdown_signal();
|
||||
swarm_secret_client::install_crypto_provider();
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
|
|
@ -322,7 +323,22 @@ async fn main() -> anyhow::Result<()> {
|
|||
tracing::info!(socket = %args.socket.display(), "swarm-metrics-auth listening");
|
||||
|
||||
let app = axum::Router::new().fallback(handle).with_state(responder);
|
||||
axum::serve(listener, app).await.context("serving")
|
||||
serve(listener, app, stop).await
|
||||
}
|
||||
|
||||
/// Answers on `listener` until `stop` resolves, then lets the requests in hand
|
||||
/// finish, for at most the drain, and returns.
|
||||
async fn serve(
|
||||
listener: tokio::net::UnixListener,
|
||||
app: axum::Router,
|
||||
stop: impl Future<Output = ()> + Clone + Send + 'static,
|
||||
) -> anyhow::Result<()> {
|
||||
let serving = axum::serve(listener, app).with_graceful_shutdown(stop.clone());
|
||||
swarm_secret_client::serve_bounded(stop, serving.into_future())
|
||||
.await
|
||||
.transpose()
|
||||
.context("serving")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue