From c8cadf23fc0d0722ce94deb781ed0d057dcd8407 Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Wed, 7 Aug 2024 21:34:19 +0300 Subject: [PATCH] fix: don't open browser window on boot if running in `detached` mode --- kinode/src/main.rs | 7 ++++--- kinode/src/register.rs | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kinode/src/main.rs b/kinode/src/main.rs index fd9742b8..ba7e45b2 100644 --- a/kinode/src/main.rs +++ b/kinode/src/main.rs @@ -78,7 +78,7 @@ async fn main() { let password = matches.get_one::("password"); // detached determines whether terminal is interactive - let is_detached = *matches.get_one::("detached").unwrap(); + let detached = *matches.get_one::("detached").unwrap(); #[cfg(feature = "simulation-mode")] let (fake_node_name, fakechain_port) = ( @@ -420,7 +420,7 @@ async fn main() { kernel_debug_message_sender, print_sender.clone(), print_receiver, - is_detached, + detached, verbose_mode, ) => { match quit { @@ -730,7 +730,8 @@ async fn serve_register_fe( (tcp_networking.0.as_ref(), tcp_networking.1), http_server_port, disk_keyfile, - maybe_rpc) => { + maybe_rpc, + detached) => { panic!("registration failed") } Some((our, decoded_keyfile, encoded_keyfile)) = rx.recv() => { diff --git a/kinode/src/register.rs b/kinode/src/register.rs index 36d2118c..8ad7cc7a 100644 --- a/kinode/src/register.rs +++ b/kinode/src/register.rs @@ -41,6 +41,7 @@ pub async fn register( http_port: u16, keyfile: Option>, maybe_rpc: Option, + detached: bool, ) { // Networking info is generated and passed to the UI, but not used until confirmed let (public_key, serialized_networking_keypair) = keygen::generate_networking_key(); @@ -211,7 +212,9 @@ pub async fn register( .or(api) .with(warp::reply::with::headers(headers)); - let _ = open::that(format!("http://localhost:{}/", http_port)); + if !detached { + let _ = open::that(format!("http://localhost:{}/", http_port)); + } warp::serve(routes) .bind_with_graceful_shutdown(([0, 0, 0, 0], http_port), async { kill_rx.await.ok();