Skip to content

Running actix-web from tauri async runtime #2942

Answered by FabianLars
joepio asked this question in Q&A
Discussion options

You must be logged in to vote

Hmm, i think the easiest (might not be the best way lol) would be to create an actix runtime on a seperate std thread. so in your specific case you'd end up with something like this:

fn main() {
  let ctx = tauri::generate_context!();

  let config: atomic_server_lib::config::Config = atomic_server_lib::config::init()
    .map_err(|e| format!("Initialization failed: {}", e))
    .expect("failed init config");
  let config_clone = config.clone();

  std::thread::spawn(move || {
    let rt = actix_rt::Runtime::new().unwrap();
    rt.block_on(atomic_server_lib::serve::serve(&config_clone));
  });

  tauri::Builder::default()
    .menu(crate::menu::build(&ctx))
    .on_menu_event(crate::menu::h…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by joepio
Comment options

You must be logged in to vote
2 replies
@FabianLars
Comment options

@joepio
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants