Skip to main content

run_with_shutdown

Function run_with_shutdown 

Source
pub async fn run_with_shutdown<F, Fut>(run: F) -> Result<()>
where F: FnOnce(CancellationToken) -> Fut, Fut: Future<Output = Result<()>>,
Expand description

Runs a service future until it completes or a shutdown signal is received.

On SIGTERM or Ctrl-C, the provided root cancellation token is cancelled and the service future is given GRACE_PERIOD to complete. If it does not, the process exits immediately so blocking work cannot hold the Tokio runtime alive indefinitely.