Skip to content

Commit 9e26092

Browse files
mamcxbfops
andauthored
Improve message error if the port is taken (#3320)
# Description of Changes As the title says # Expected complexity level and risk 1 # Testing - [x] Manually check the error launching a local pg instance Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
1 parent 7aae091 commit 9e26092

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • crates/standalone/src/subcommands

crates/standalone/src/subcommands/start.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,17 @@ pub async fn exec(args: &ArgMatches, db_cores: JobCores) -> anyhow::Result<()> {
186186
let extra = axum::Router::new().nest("/health", spacetimedb_client_api::routes::health::router());
187187
let service = router(&ctx, db_routes, extra).with_state(ctx.clone());
188188

189-
let tcp = TcpListener::bind(listen_addr).await?;
189+
let tcp = TcpListener::bind(listen_addr).await.context(format!(
190+
"failed to bind the SpacetimeDB server to '{listen_addr}', please check that the address is valid and not already in use"
191+
))?;
190192
socket2::SockRef::from(&tcp).set_nodelay(true)?;
191193
log::info!("Starting SpacetimeDB listening on {}", tcp.local_addr()?);
192194

193195
if let Some(pg_port) = pg_port {
194196
let server_addr = listen_addr.split(':').next().unwrap();
195-
let tcp_pg = TcpListener::bind(format!("{server_addr}:{pg_port}")).await?;
197+
let tcp_pg = TcpListener::bind(format!("{server_addr}:{pg_port}")).await.context(format!(
198+
"failed to bind the SpacetimeDB PostgreSQL wire protocol server to {server_addr}:{pg_port}, please check that the port is valid and not already in use"
199+
))?;
196200

197201
let notify = Arc::new(tokio::sync::Notify::new());
198202
let shutdown_notify = notify.clone();

0 commit comments

Comments
 (0)