1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 21:51:06 +01:00

tweak server logging

This commit is contained in:
Rob Ede 2021-10-22 18:17:26 +01:00
parent a1d15f2e08
commit 1c8fcaebbc
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
3 changed files with 19 additions and 15 deletions

View File

@ -5,7 +5,7 @@ use actix_rt::{
time::{sleep, Instant},
System,
};
use log::{error, info};
use log::{debug, error, info};
use mio::{Interest, Poll, Token as MioToken};
use crate::server::Server;
@ -229,7 +229,7 @@ impl Accept {
WAKER_TOKEN => {
let exit = self.handle_waker(sockets);
if exit {
info!("Accept is stopped.");
info!("Accept thread stopped");
return;
}
}
@ -365,14 +365,14 @@ impl Accept {
fn register_logged(&self, info: &mut ServerSocketInfo) {
match self.register(info) {
Ok(_) => info!("Resume accepting connections on {}", info.lst.local_addr()),
Ok(_) => debug!("Resume accepting connections on {}", info.lst.local_addr()),
Err(e) => error!("Can not register server socket {}", e),
}
}
fn deregister_logged(&self, info: &mut ServerSocketInfo) {
match self.poll.registry().deregister(&mut info.lst) {
Ok(_) => info!("Paused accepting connections on {}", info.lst.local_addr()),
Ok(_) => debug!("Paused accepting connections on {}", info.lst.local_addr()),
Err(e) => {
error!("Can not deregister server socket {}", e)
}

View File

@ -250,7 +250,14 @@ impl ServerBuilder {
if self.sockets.is_empty() {
panic!("Server should have at least one bound socket");
} else {
info!("Starting {} workers", self.threads);
for (_, name, lst) in &self.sockets {
info!(
r#"Starting service: "{}", workers: {}, listening on: {}"#,
name,
self.threads,
lst.local_addr()
);
}
// start workers
let handles = (0..self.threads)
@ -264,9 +271,6 @@ impl ServerBuilder {
.collect();
// start accept thread
for sock in &self.sockets {
info!("Starting \"{}\" service on {}", sock.1, sock.2);
}
self.accept.start(
mem::take(&mut self.sockets)
.into_iter()
@ -312,7 +316,7 @@ impl ServerBuilder {
// Handle `SIGINT`, `SIGTERM`, `SIGQUIT` signals and stop actix system
match sig {
Signal::Int => {
info!("SIGINT received, starting forced shutdown");
info!("SIGINT received; starting forced shutdown");
self.exit = true;
self.handle_cmd(ServerCommand::Stop {
graceful: false,
@ -321,7 +325,7 @@ impl ServerBuilder {
}
Signal::Term => {
info!("SIGTERM received, starting graceful shutdown");
info!("SIGTERM received; starting graceful shutdown");
self.exit = true;
self.handle_cmd(ServerCommand::Stop {
graceful: true,
@ -330,7 +334,7 @@ impl ServerBuilder {
}
Signal::Quit => {
info!("SIGQUIT received, starting forced shutdown");
info!("SIGQUIT received; starting forced shutdown");
self.exit = true;
self.handle_cmd(ServerCommand::Stop {
graceful: false,
@ -390,7 +394,7 @@ impl ServerBuilder {
}
if found {
error!("Worker has died {:?}, restarting", idx);
error!("Worker {} has died; restarting", idx);
let mut new_idx = self.handles.len();
'found: loop {

View File

@ -466,11 +466,11 @@ impl Future for ServerWorker {
{
let num = this.counter.total();
if num == 0 {
info!("Shutting down worker, 0 connections");
info!("Shutting down idle worker");
let _ = tx.send(true);
return Poll::Ready(());
} else if graceful {
info!("Graceful worker shutdown, {} connections", num);
info!("Graceful worker shutdown; finishing {} connections", num);
this.shutdown(false);
this.state = WorkerState::Shutdown(Shutdown {
@ -479,7 +479,7 @@ impl Future for ServerWorker {
tx,
});
} else {
info!("Force shutdown worker, {} connections", num);
info!("Force shutdown worker, closing {} connections", num);
this.shutdown(true);
let _ = tx.send(false);