Create tokio runtime for async setup tasks

This commit is contained in:
2026-06-23 22:00:10 -04:00
parent 655afa77ac
commit cc468b5b14

View File

@@ -1,3 +1,5 @@
use tokio::runtime::Runtime;
use crate::App; use crate::App;
use crate::server::config; use crate::server::config;
use crate::util::error::{Contextualize, Error, Result}; use crate::util::error::{Contextualize, Error, Result};
@@ -12,6 +14,14 @@ pub fn main() -> Result<()> {
.map_err(|e| Error::message_here(e.to_string())) .map_err(|e| Error::message_here(e.to_string()))
.err_context("Failed to load config")?; .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..."); tracing::info!("Setup complete, launching web server...");
dioxus::launch(App); dioxus::launch(App);