Skip to main content

spawn_termination_signal_handler

Function spawn_termination_signal_handler 

Source
pub fn spawn_termination_signal_handler<F, Fut>(
    shutdown_token: CancellationToken,
    on_signal: F,
) -> JoinHandle<()>
where F: FnOnce() -> Fut + Send + 'static, Fut: Future<Output = ()> + Send + 'static,
Expand description

Spawns a task that waits for a termination signal, cancels shutdown_token, and then runs on_signal.

This keeps product entrypoints from duplicating the same signal-listener task while leaving the actual server stop primitive product-specific.