Skip to content

Commit e517a45

Browse files
committed
Shutdown tracing after runtime
This makes the overall exporter race a bit more resilient against race conditions. Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
1 parent a0b146d commit e517a45

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

conmon-rs/server/src/server.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,15 @@ impl Server {
9090
.map_err(errno::from_i32)
9191
.context("set child subreaper")?;
9292

93+
let enable_tracing = self.config().enable_tracing();
94+
9395
let rt = Builder::new_multi_thread().enable_all().build()?;
9496
rt.block_on(self.spawn_tasks())?;
97+
98+
if enable_tracing {
99+
Telemetry::shutdown();
100+
}
101+
95102
rt.shutdown_background();
96103
Ok(())
97104
}
@@ -212,16 +219,12 @@ impl Server {
212219
async fn start_backend(self, mut shutdown_rx: oneshot::Receiver<()>) -> Result<()> {
213220
let listener =
214221
Listener::<DefaultListener>::default().bind_long_path(&self.config().socket())?;
215-
let enable_tracing = self.config().enable_tracing();
216222
let client: conmon::Client = capnp_rpc::new_client(self);
217223

218224
loop {
219225
let stream = tokio::select! {
220226
_ = &mut shutdown_rx => {
221227
debug!("Received shutdown message");
222-
if enable_tracing {
223-
Telemetry::shutdown();
224-
}
225228
return Ok(())
226229
}
227230
stream = listener.accept() => {

0 commit comments

Comments
 (0)