From e517a45c77afae7f4579a192aeb32ab34134b19d Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Fri, 14 Oct 2022 12:05:43 +0200 Subject: [PATCH] Shutdown tracing after runtime This makes the overall exporter race a bit more resilient against race conditions. Signed-off-by: Sascha Grunert --- conmon-rs/server/src/server.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/conmon-rs/server/src/server.rs b/conmon-rs/server/src/server.rs index b3af5d060b..8a12a11092 100644 --- a/conmon-rs/server/src/server.rs +++ b/conmon-rs/server/src/server.rs @@ -90,8 +90,15 @@ impl Server { .map_err(errno::from_i32) .context("set child subreaper")?; + let enable_tracing = self.config().enable_tracing(); + let rt = Builder::new_multi_thread().enable_all().build()?; rt.block_on(self.spawn_tasks())?; + + if enable_tracing { + Telemetry::shutdown(); + } + rt.shutdown_background(); Ok(()) } @@ -212,16 +219,12 @@ impl Server { async fn start_backend(self, mut shutdown_rx: oneshot::Receiver<()>) -> Result<()> { let listener = Listener::::default().bind_long_path(&self.config().socket())?; - let enable_tracing = self.config().enable_tracing(); let client: conmon::Client = capnp_rpc::new_client(self); loop { let stream = tokio::select! { _ = &mut shutdown_rx => { debug!("Received shutdown message"); - if enable_tracing { - Telemetry::shutdown(); - } return Ok(()) } stream = listener.accept() => {