only use graceful shutdown w/ axum-server fixed
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
04fc87ad07
commit
463f1a1287
1 changed files with 11 additions and 11 deletions
|
@ -12,7 +12,7 @@ extern crate conduit_service as service;
|
||||||
|
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
use conduit::{debug, debug_info, error, info, trace, Error, Result, Server};
|
use conduit::{debug, debug_info, error, info, Error, Result, Server};
|
||||||
|
|
||||||
use crate::serve;
|
use crate::serve;
|
||||||
|
|
||||||
|
@ -103,20 +103,20 @@ async fn signal(server: Arc<Server>, tx: Sender<()>, handle: axum_server::Handle
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_shutdown(server: &Arc<Server>, tx: &Sender<()>, handle: &axum_server::Handle, sig: &str) {
|
async fn handle_shutdown(server: &Arc<Server>, tx: &Sender<()>, handle: &axum_server::Handle, sig: &str) {
|
||||||
debug!("Received signal {}", sig);
|
debug!("Received signal {sig}");
|
||||||
if let Err(e) = tx.send(()) {
|
if let Err(e) = tx.send(()) {
|
||||||
error!("failed sending shutdown transaction to channel: {e}");
|
error!("failed sending shutdown transaction to channel: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
let pending = server.metrics.requests_spawn_active.load(Ordering::Relaxed);
|
let timeout = Duration::from_secs(36);
|
||||||
if pending > 0 {
|
debug!(
|
||||||
let timeout = Duration::from_secs(36);
|
?timeout,
|
||||||
trace!(pending, ?timeout, "Notifying for graceful shutdown");
|
spawn_active = ?server.metrics.requests_spawn_active.load(Ordering::Relaxed),
|
||||||
handle.graceful_shutdown(Some(timeout));
|
handle_active = ?server.metrics.requests_handle_active.load(Ordering::Relaxed),
|
||||||
} else {
|
"Notifying for graceful shutdown"
|
||||||
debug!(pending, "Notifying for immediate shutdown");
|
);
|
||||||
handle.shutdown();
|
|
||||||
}
|
handle.graceful_shutdown(Some(timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_services_poll(
|
async fn handle_services_poll(
|
||||||
|
|
Loading…
Add table
Reference in a new issue