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 # Changes
## [2.6.1] - 2024-12-26
* Tune shutdown logging
## [2.6.0] - 2024-12-04 ## [2.6.0] - 2024-12-04
* Use updated Service trait * Use updated Service trait

View file

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

View file

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

View file

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