Skip to content

Commit

Permalink
Shutdown tracing after runtime
Browse files Browse the repository at this point in the history
This makes the overall exporter race a bit more resilient against race
conditions.

Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Oct 14, 2022
1 parent a0b146d commit e517a45
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions conmon-rs/server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down Expand Up @@ -212,16 +219,12 @@ impl Server {
async fn start_backend(self, mut shutdown_rx: oneshot::Receiver<()>) -> Result<()> {
let listener =
Listener::<DefaultListener>::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() => {
Expand Down

0 comments on commit e517a45

Please sign in to comment.