From 1a309344a01bb4668056daad8347ceebf5d918f1 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Thu, 14 Nov 2024 15:48:44 +0100 Subject: [PATCH] Let the WebSocket server serve its data even without the web-viewer feature (#8145) * Fixes https://github.com/rerun-io/rerun/issues/8140 * [x] :ship: --- crates/store/re_ws_comms/src/server.rs | 9 +++++++++ crates/top/rerun/src/commands/entrypoint.rs | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/crates/store/re_ws_comms/src/server.rs b/crates/store/re_ws_comms/src/server.rs index 08c737921c3f..c3324c631640 100644 --- a/crates/store/re_ws_comms/src/server.rs +++ b/crates/store/re_ws_comms/src/server.rs @@ -171,6 +171,15 @@ impl RerunServer { self.num_accepted_clients.load(Ordering::Relaxed) } + /// Blocks execution as long as the server is running. + /// + /// There's no way of shutting the server down from the outside right now. + pub fn block(mut self) { + if let Some(listener_join_handle) = self.listener_join_handle.take() { + listener_join_handle.join().ok(); + } + } + fn listen_thread_func( poller: &Poller, listener_socket: &TcpListener, diff --git a/crates/top/rerun/src/commands/entrypoint.rs b/crates/top/rerun/src/commands/entrypoint.rs index 5e51df354c87..b7ed10fe9a8d 100644 --- a/crates/top/rerun/src/commands/entrypoint.rs +++ b/crates/top/rerun/src/commands/entrypoint.rs @@ -795,6 +795,12 @@ fn run_impl( .block(); // dropping should stop the server } + #[cfg(not(feature = "web_viewer"))] + { + // Returning from this function so soon would drop and therefore stop the server. + _ws_server.block(); + } + return Ok(()); } } else if is_another_viewer_running {