Skip to content

Commit a29aaae

Browse files
committed
feat: [torrust#1477] add server address to http server shutdown logs
1 parent bbc0154 commit a29aaae

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

packages/axum-health-check-api-server/src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub fn start(
113113
handle.clone(),
114114
rx_halt,
115115
format!("Shutting down http server on socket address: {address}"),
116+
address,
116117
));
117118

118119
let running = axum_server::from_tcp(socket)

packages/axum-http-tracker-server/src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ impl Launcher {
6060
handle.clone(),
6161
rx_halt,
6262
format!("Shutting down HTTP server on socket address: {address}"),
63+
address,
6364
));
6465

6566
let tls = self.tls.clone();

packages/axum-rest-tracker-api-server/src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ impl Launcher {
257257
handle.clone(),
258258
rx_halt,
259259
format!("Shutting down tracker API server on socket address: {address}"),
260+
address,
260261
));
261262

262263
let tls = self.tls.clone();

packages/axum-server/src/signals.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
1+
use std::net::SocketAddr;
12
use std::time::Duration;
23

34
use tokio::time::{sleep, Instant};
45
use torrust_server_lib::signals::{shutdown_signal_with_message, Halted};
56
use tracing::instrument;
67

78
#[instrument(skip(handle, rx_halt, message))]
8-
pub async fn graceful_shutdown(handle: axum_server::Handle, rx_halt: tokio::sync::oneshot::Receiver<Halted>, message: String) {
9-
shutdown_signal_with_message(rx_halt, message).await;
9+
pub async fn graceful_shutdown(
10+
handle: axum_server::Handle,
11+
rx_halt: tokio::sync::oneshot::Receiver<Halted>,
12+
message: String,
13+
address: SocketAddr,
14+
) {
15+
shutdown_signal_with_message(rx_halt, message.clone()).await;
1016

1117
let grace_period = Duration::from_secs(90);
1218
let max_wait = Duration::from_secs(95);
1319
let start = Instant::now();
1420

1521
handle.graceful_shutdown(Some(grace_period));
1622

17-
tracing::info!("!! Shutting down http server in {} seconds !!", grace_period.as_secs());
23+
tracing::info!("!! {} in {} seconds !!", message, grace_period.as_secs());
1824

1925
loop {
2026
if handle.connection_count() == 0 {
21-
tracing::info!("All connections closed, shutting down server");
27+
tracing::info!("All connections closed, shutting down server in address {}", address);
2228
break;
2329
}
2430

2531
if start.elapsed() >= max_wait {
2632
tracing::warn!(
27-
"Shutdown timeout of {} seconds reached. Forcing shutdown with {} active connections.",
33+
"Shutdown timeout of {} seconds reached. Forcing shutdown in address {} with {} active connections.",
2834
max_wait.as_secs(),
35+
address,
2936
handle.connection_count()
3037
);
3138
break;

0 commit comments

Comments
 (0)