From 6eb18fe3fb51f41a83bd07063d2fc34953c20ccf Mon Sep 17 00:00:00 2001 From: Reinier Maas Date: Tue, 23 Dec 2025 15:32:00 +0100 Subject: [PATCH] Log: locally bound server address This includes the port that is selected if one tries to bind to port `0`. --- opsqueue/app/main.rs | 1 - opsqueue/src/server.rs | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/opsqueue/app/main.rs b/opsqueue/app/main.rs index e3cc6d6..010ffa0 100644 --- a/opsqueue/app/main.rs +++ b/opsqueue/app/main.rs @@ -67,7 +67,6 @@ pub async fn async_main() { "Startup of Opsqueue ({}) complete.", opsqueue::version_info() ); - tracing::info!("Listening on {}", &server_addr); tokio::signal::ctrl_c() .await diff --git a/opsqueue/src/server.rs b/opsqueue/src/server.rs index b935963..f983141 100644 --- a/opsqueue/src/server.rs +++ b/opsqueue/src/server.rs @@ -44,7 +44,12 @@ pub async fn serve_producer_and_consumer( prometheus_config.clone(), ); let listener = tokio::net::TcpListener::bind(server_addr).await?; - + match listener.local_addr() { + Ok(addr) => tracing::info!("Server listening on {addr}"), + Err(err) => tracing::warn!( + "Could not get locally bound address of the server, tried binding on {server_addr}: {err}" + ), + } axum::serve(listener, router) .with_graceful_shutdown(cancellation_token.clone().cancelled_owned()) .await?;