Watch
0
0
Fork
You've already forked hyperhive
0

swarm-logs-auth, swarm-metrics-auth, swarm-authelia-bridge, swarm-controller: drain http on sigterm

This commit is contained in:
atlas 2026-11-18 03:28:12 +01:00 • committed by mara
commit a089da25a5

View file

@ -106,6 +106,7 @@ struct AppState {
#[tokio::main]
async fn main() -> Result<()> {
let stop = swarm_secret_client::shutdown_signal();
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into()),
@ -130,9 +131,22 @@ async fn main() -> Result<()> {
let listener = bind_socket(&socket)?;
tracing::info!(socket = %socket.display(), "swarm-authelia-bridge listening");
axum::serve(listener, app)
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: Router,
stop: impl Future<Output = ()> + Clone + Send + 'static,
) -> Result<()> {
let serving = axum::serve(listener, app).with_graceful_shutdown(stop.clone());
swarm_secret_client::serve_bounded(stop, serving.into_future())
.await
.context("serving swarm-authelia-bridge")
.transpose()
.context("serving swarm-authelia-bridge")?;
Ok(())
}
/// Bind the listening socket at `path`, replacing a stale one a crash left