Skip to main content

serve_until

Function serve_until 

Source
pub fn serve_until<H>(
    addr: &str,
    workers: usize,
    limits: Limits,
    handler: H,
    shutdown: Arc<AtomicBool>,
) -> Result<()>
where H: Fn(Request) -> Response + Send + Sync + 'static,
Expand description

Like serve, but stops accepting new connections once shutdown is set, then drains in-flight requests (by dropping the pool, which joins workers) and returns. This is what makes a sutegi process safe to roll in a pod: on SIGTERM you flip the flag, stop taking traffic, and let live requests finish within the termination grace period.