Tune shutdown logging (#489)

This commit is contained in:
Nikolay Kim 2024-12-26 10:05:25 +01:00 committed by GitHub
parent b5be9502b4
commit 80676aa242
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 8 deletions

View file

@ -1,5 +1,9 @@
# Changes
## [2.6.1] - 2024-12-26
* Tune shutdown logging
## [2.6.0] - 2024-12-04
* Use updated Service trait

View file

@ -1,6 +1,6 @@
[package]
name = "ntex-server"
version = "2.6.0"
version = "2.6.1"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Server for ntex framework"
keywords = ["network", "framework", "async", "futures"]

View file

@ -262,10 +262,10 @@ impl<F: ServerConfiguration> HandleCmdState<F> {
for tx in notify {
let _ = tx.send(());
}
sleep(STOP_DELAY).await;
// stop system if server was spawned
if self.mgr.0.cfg.stop_runtime {
sleep(STOP_DELAY).await;
System::current().stop();
}
}

View file

@ -215,13 +215,13 @@ impl Accept {
for info in self.sockets.drain(..) {
info.sock.remove_source()
}
log::info!("Accept loop has been stopped");
if let Some(rx) = rx {
thread::sleep(EXIT_TIMEOUT);
let _ = rx.send(());
}
log::trace!("Accept loop has been stopped");
break;
}
}
@ -295,25 +295,25 @@ impl Accept {
Ok(cmd) => match cmd {
AcceptorCommand::Stop(rx) => {
if !self.backpressure {
log::trace!("Stopping accept loop");
log::info!("Stopping accept loop");
self.backpressure(true);
}
break Either::Right(Some(rx));
}
AcceptorCommand::Terminate => {
log::trace!("Stopping accept loop");
log::info!("Stopping accept loop");
self.backpressure(true);
break Either::Right(None);
}
AcceptorCommand::Pause => {
if !self.backpressure {
log::trace!("Pausing accept loop");
log::info!("Pausing accept loop");
self.backpressure(true);
}
}
AcceptorCommand::Resume => {
if self.backpressure {
log::trace!("Resuming accept loop");
log::info!("Resuming accept loop");
self.backpressure(false);
}
}
@ -322,13 +322,14 @@ impl Accept {
}
},
Err(err) => {
log::error!("Dropping accept loop");
break match err {
mpsc::TryRecvError::Empty => Either::Left(()),
mpsc::TryRecvError::Disconnected => {
self.backpressure(true);
Either::Right(None)
}
}
};
}
}
}