Skip to content

Commit

Permalink
Tune shutdown logging (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 authored Dec 26, 2024
1 parent b5be950 commit 80676aa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ntex-server/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [2.6.1] - 2024-12-26

* Tune shutdown logging

## [2.6.0] - 2024-12-04

* Use updated Service trait
Expand Down
2 changes: 1 addition & 1 deletion ntex-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion ntex-server/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
13 changes: 7 additions & 6 deletions ntex-server/src/net/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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)
}
}
};
}
}
}
Expand Down

0 comments on commit 80676aa

Please # to comment.