Skip to main content

serve_with_shutdown

Function serve_with_shutdown 

Source
pub async fn serve_with_shutdown<C>(
    addr: SocketAddr,
    state: AppState<C>,
    shutdown: impl Future<Output = ()> + Send + 'static,
) -> Result<(), Error>
where C: ComputeBackend + Clone + Send + Sync + 'static,
Expand description

Bind addr and serve until shutdown resolves or the listener fails.

Stops accepting once shutdown fires, then waits for outstanding requests to drain. Note that long-lived kernel WebSocket tunnels never “finish”: the caller that needs a bounded exit should race this future and drop it (waratah_bin does exactly that).