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())