Skip to content
Snippets Groups Projects
Commit 3ff5bc52 authored by 🥺's avatar 🥺 :transgender_flag: Committed by 🥺
Browse files

ask systemd for more time when shutting down if needed, raise axum shutdown timeout to 3 mins

parent 0b171a2b
No related branches found
No related tags found
No related merge requests found
...@@ -565,14 +565,28 @@ async fn shutdown_signal(handle: ServerHandle, tx: Sender<()>) -> Result<()> { ...@@ -565,14 +565,28 @@ async fn shutdown_signal(handle: ServerHandle, tx: Sender<()>) -> Result<()> {
} }
warn!("Received {}, shutting down...", sig); warn!("Received {}, shutting down...", sig);
handle.graceful_shutdown(Some(Duration::from_secs(60))); let shutdown_time_elapsed = tokio::time::Instant::now();
handle.graceful_shutdown(Some(Duration::from_secs(180)));
services().globals.shutdown(); services().globals.shutdown();
#[cfg(feature = "systemd")] #[cfg(feature = "systemd")]
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Stopping]); let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Stopping]);
tx.send(()).unwrap(); tx.send(()).unwrap();
if shutdown_time_elapsed.elapsed() >= Duration::from_secs(60) && cfg!(feature = "systemd") {
warn!("Still shutting down after 60 seconds since receiving shutdown signal, asking systemd for more time (+120 seconds). Remaining connections: {}", handle.connection_count());
#[cfg(feature = "systemd")]
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::ExtendTimeoutUsec(120)]);
}
warn!(
"Time took to shutdown: {:?} seconds",
shutdown_time_elapsed.elapsed()
);
Ok(()) Ok(())
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment