pub fn with_graceful_shutdown<F>(self, signal: F) -> Graceful<I, S, F, E>
    where
        F: Future<Output = ()>,
    {
        Graceful::new(self.spawn_all, signal)
    }
/// Prepares a server to handle graceful shutdown when the provided future
/// completes.
///
/// # Example
///
/// ```
/// # fn main() {}
/// # #[cfg(feature = "tcp")]
/// # async fn run() {
/// # use hyper::{Body, Response, Server, Error};
/// # use hyper::service::{make_service_fn, service_fn};
/// # let make_service = make_service_fn(|_| async {
/// #     Ok::<_, Error>(service_fn(|_req| async {
/// #         Ok::<_, Error>(Response::new(Body::from("Hello World")))
/// #     }))
/// # });
/// // Make a server from the previous examples...
/// let server = Server::bind(&([127, 0, 0, 1], 3000).into())
///     .serve(make_service);
///
/// // Prepare some signal for when the server should start shutting down...
/// let (tx, rx) = tokio::sync::oneshot::channel::<()>();
/// let graceful = server
///     .with_graceful_shutdown(async {
///         rx.await.ok();
///     });
///
/// // Await the `server` receiving the signal...
/// if let Err(e) = graceful.await {
///     eprintln!("server error: {}", e);
/// }
///
/// // And later, trigger the signal by calling `tx.send(())`.
/// let _ = tx.send(());
/// # }
/// ```
Prepares a server to handle graceful shutdown when the provided future
completes.
Prepares a server to handle graceful shutdown when the provided future completes .
pub fn with_graceful_shutdown<F>(self, signal: F) -> Graceful<I, S, F, E>
    where
        F: Future<Output = ()>,
    {
        Graceful::new(self.spawn_all, signal)
    }
pub fn with_graceful_shutdown < F > ( self , signal : F ) -> Graceful < I , S , F , E > where F : Future < Output = ( ) > , { Graceful :: new ( self . spawn_all , signal ) }
Prepares a server to handle graceful shutdown when the provided future
completes.
Prepares a server to handle graceful shutdown when the provided future completes .
self
signal
F
self
signal
F
example
None
fn main() {}
None
#[cfg(feature = "tcp")]
None
async fn run() {
None
use hyper::{body, response, server, error};
None
use hyper::service::{make_service_fn, service_fn};
None
let make_service = make_service_fn(|_| async {
None
ok::<_, error>(service_fn(|_req| async {
None
ok::<_, error>(response::new(body::from("hello world")))
None
}))
None
});
Make a server from the previous examples
let server = Server::bind(&([127, 0, 0, 1], 3000).into())
.serve(make_service).

Prepare some signal for when the server should start shutting down
let (tx, rx) = tokio::sync::oneshot::channel::<()>();
let graceful = server
.with_graceful_shutdown(async {
rx.await.ok();
}).

Await the `server` receiving the signal
if let Err(e) = graceful.await {
eprintln!("server error: {}", e);
}

And later, trigger the signal by calling `tx.send(())`.
Make a server from the previous examples let server = Server :: bind ( & ( [ 127 0 0 1 ] 3000 ) . into () ) . serve ( make_service ) . Prepare some signal for when the server should start shutting down let ( tx rx ) = tokio :: sync :: oneshot :: channel :: < () > () ; let graceful = server . with_graceful_shutdown ( async { rx . await . ok () ; } ) . Await the ` server ` receiving the signal if let Err ( e ) = graceful . await { eprintln! ( " server error : {} " e ) ; } And later trigger the signal by calling ` tx . send (( )) ` .
}
None