Unverified Commit fa4ce46c authored by KrishnanPrash's avatar KrishnanPrash Committed by GitHub
Browse files

fix: Improve Error Messaging for port/address already in use error (#3587)


Signed-off-by: default avatarKrishnan Prashanth <kprashanth@nvidia.com>
parent b5e762b2
...@@ -267,9 +267,27 @@ impl HttpService { ...@@ -267,9 +267,27 @@ impl HttpService {
} }
} }
} else { } else {
let listener = tokio::net::TcpListener::bind(addr) let listener = tokio::net::TcpListener::bind(addr).await.map_err(|e| {
.await tracing::error!(
.unwrap_or_else(|_| panic!("could not bind to address: {address}")); protocol = %protocol,
address = %address,
error = %e,
"Failed to bind server to address"
);
match e.kind() {
std::io::ErrorKind::AddrInUse => anyhow::anyhow!(
"Failed to start {} server: port {} already in use. Use --http-port to specify a different port.",
protocol,
self.port
),
_ => anyhow::anyhow!(
"Failed to start {} server on {}: {}",
protocol,
address,
e
),
}
})?;
axum::serve(listener, router) axum::serve(listener, router)
.with_graceful_shutdown(observer.cancelled_owned()) .with_graceful_shutdown(observer.cancelled_owned())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment