Skip to main content

serve_with_shutdown

Function serve_with_shutdown 

Source
pub async fn serve_with_shutdown<F>(
    listener: TcpListener,
    router: Router,
    shutdown: F,
) -> Result<(), ServerError>
where F: Future<Output = ()> + Send + 'static,
Expand description

Serve router on listener, draining in-flight requests once shutdown resolves.

shutdown is any future — crate::shutdown_signal is a ready-made one that resolves on Ctrl+C or SIGTERM.