Skip to content

ui: Enable both native and webui on single binary - #348

Merged
altonen merged 3 commits into
eepnet:masterfrom
cappuccinocosmico:enable-both-native-and-webui-on-single-binary
Apr 27, 2026
Merged

altonen merged 3 commits into
eepnet:masterfrom
cappuccinocosmico:enable-both-native-and-webui-on-single-binary

Conversation

@cappuccinocosmico

@cappuccinocosmico cappuccinocosmico commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Includes the fix mentioned in #344.

Comment thread emissary-cli/src/main.rs
router_event_loop(router, port_mapper, shutdown_rx).await;
std::process::exit(0);
});
ui::native::RouterUi::start(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After iced upgrade (#320), the native UI internally calls tokio::spawn() so a runtime must be active. With these changes alone the native UI is unable to start but with the patch below both UIs work:

diff --git a/emissary-cli/src/main.rs b/emissary-cli/src/main.rs
index 7d1eeb3..c4ef0db 100644
--- a/emissary-cli/src/main.rs
+++ b/emissary-cli/src/main.rs
@@ -55,8 +55,6 @@ mod tools;
 mod tunnel;
 mod ui;
 
-
-
 /// Logging target for the file.
 const LOG_TARGET: &str = "emissary";
 
@@ -474,10 +472,10 @@ fn main() -> anyhow::Result<()> {
 }
 
 #[cfg(all(feature = "native-ui", feature = "web-ui"))]
-fn main() -> anyhow::Result<()> {
-    let runtime = tokio::runtime::Runtime::new()?;
+#[tokio::main]
+async fn main() -> anyhow::Result<()> {
     let (shutdown_tx, shutdown_rx) = channel(1);
-    let arguments = runtime.block_on(parse_arguments());
+    let arguments = parse_arguments().await;
     let RouterContext {
         router,
         port_mapper,
@@ -488,30 +486,30 @@ fn main() -> anyhow::Result<()> {
         address_book_handle,
         router_id,
         ..
-    } = runtime.block_on(setup_router::<TokioRuntime>(arguments))?;
+    } = setup_router::<TokioRuntime>(arguments).await?;
 
     let use_web_ui = router_ui_config.as_ref().and_then(|c| c.web_ui).unwrap_or(false);
 
     if use_web_ui {
         match router_ui_config {
             None => {
-                runtime.block_on(router_event_loop(router, port_mapper, shutdown_rx));
+                router_event_loop(router, port_mapper, shutdown_rx).await;
             }
             Some(RouterUiConfig {
                 refresh_interval,
                 port,
                 ..
             }) => {
-                runtime.spawn(async move {
+                tokio::spawn(async move {
                     ui::web::RouterUi::new(events, port, refresh_interval, shutdown_tx).run().await;
                 });
-                runtime.block_on(router_event_loop(router, port_mapper, shutdown_rx));
+                router_event_loop(router, port_mapper, shutdown_rx).await;
             }
         }
     } else {
         match router_ui_config {
             None => {
-                runtime.block_on(router_event_loop(router, port_mapper, shutdown_rx));
+                router_event_loop(router, port_mapper, shutdown_rx).await;
             }
             Some(RouterUiConfig { .. }) => {
                 tokio::spawn(async move {

@altonen
altonen merged commit 2106845 into eepnet:master Apr 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ui: Enable Compilation with both web-ui and native-ui for easier binary distribution

2 participants