fix: don't open browser window on boot if running in detached mode

This commit is contained in:
dr-frmr 2024-08-07 21:34:19 +03:00
parent 9918896139
commit c8cadf23fc
No known key found for this signature in database
2 changed files with 8 additions and 4 deletions

View File

@ -78,7 +78,7 @@ async fn main() {
let password = matches.get_one::<String>("password");
// detached determines whether terminal is interactive
let is_detached = *matches.get_one::<bool>("detached").unwrap();
let detached = *matches.get_one::<bool>("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() => {

View File

@ -41,6 +41,7 @@ pub async fn register(
http_port: u16,
keyfile: Option<Vec<u8>>,
maybe_rpc: Option<String>,
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();