From 79c36a979ce5181f8825caf0d32d950ff7579914 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Mon, 30 Sep 2019 11:00:41 -0700 Subject: [PATCH] Use try_bind when building tracing endpoint. Prior to this commit, the tracing endpoint would attempt to bind the given address or panic; now, if it is unable to bind the given address it displays an error but continues running the rest of the application. This means that we can spin up multiple Zebra instances for load testing. --- zebrad/src/components/tracing.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/zebrad/src/components/tracing.rs b/zebrad/src/components/tracing.rs index c427e026..0ef17d90 100644 --- a/zebrad/src/components/tracing.rs +++ b/zebrad/src/components/tracing.rs @@ -77,9 +77,19 @@ impl TracingEndpoint { }); // XXX load tracing addr from config - let addr = "127.0.0.1:3000".parse().unwrap(); + let addr = "127.0.0.1:3000" + .parse() + .expect("Hardcoded address should be parseable"); - let server = Server::bind(&addr).serve(service); + let server = match Server::try_bind(&addr) { + Ok(s) => s, + Err(e) => { + error!("Could not open tracing endpoint listener"); + error!("Error: {}", e); + return Ok(()); + } + } + .serve(service); tokio_component.rt.spawn(async { if let Err(e) = server.await {