Create tokio runtime for async setup tasks
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
use crate::App;
|
||||
use crate::server::config;
|
||||
use crate::util::error::{Contextualize, Error, Result};
|
||||
@@ -12,6 +14,14 @@ pub fn main() -> Result<()> {
|
||||
.map_err(|e| Error::message_here(e.to_string()))
|
||||
.err_context("Failed to load config")?;
|
||||
|
||||
// `dioxus::launch` creates its own runtime, and starting a runtime inside of a runtime isn't
|
||||
// allowed. Therefore, this function can't be made async, and we must manually create a runtime
|
||||
// for any async setup tasks
|
||||
tracing::debug!("Starting setup runtime...");
|
||||
let setup_rt = Runtime::new()
|
||||
.map_err(|e| Error::message_here(e.to_string()))
|
||||
.err_context("Failed to create tokio runtime for server setup")?;
|
||||
|
||||
tracing::info!("Setup complete, launching web server...");
|
||||
dioxus::launch(App);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user