From d95ebb6f4ce4172108f4cfa80e1614e1dfd729ed Mon Sep 17 00:00:00 2001 From: "@permadeath.com" Date: Thu, 13 Aug 2026 10:53:54 -0400 Subject: [PATCH] fix(api): log the bound port, not the configured one The startup line printed config.bind_addr, so BIND_ADDR=127.0.0.1:0 - ask the OS for whichever port is free - always logged ":0" instead of whatever port actually opened. Reads listener.local_addr() instead, the resolved address axum's Listener trait already has once the bind succeeds. Needed by the next commit's dev-instance.sh, which has no other way to discover the port it just asked the OS to pick. Change-Id: I9cc00f99059ba746b8293fd2814ae726a2c5d5be --- services/api/src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/api/src/main.rs b/services/api/src/main.rs index 0e9ea61..bcf5656 100644 --- a/services/api/src/main.rs +++ b/services/api/src/main.rs @@ -11,7 +11,7 @@ mod session; use std::sync::Arc; -use axum::serve::ListenerExt; +use axum::serve::{Listener, ListenerExt}; use crate::config::Config; use crate::routes::AppState; @@ -103,7 +103,15 @@ async fn main() { tracing::debug!("set_nodelay failed: {e}"); } }); - tracing::info!("listening on {}", config.bind_addr); + // The bound address, not the configured one: BIND_ADDR=127.0.0.1:0 asks + // the OS for whichever port is free, which is what scripts/dev-instance.sh + // relies on this line to report - logging config.bind_addr back would + // always print :0 and never say which port actually opened. + let bound = listener + .local_addr() + .map(|a| a.to_string()) + .unwrap_or_else(|_| config.bind_addr.to_string()); + tracing::info!("listening on {bound}"); axum::serve(listener, routes::app(state)) .with_graceful_shutdown(shutdown_signal()) -- 2.51.2