run init load in its own thread

This commit is contained in:
Simon
2025-12-04 13:11:46 +00:00
parent 75e28608bd
commit 9e30eedc77

View File

@@ -2,7 +2,7 @@
#![allow(non_snake_case)]
use std::env;
use std::{env, thread};
use diesel::{r2d2::{self, ConnectionManager}, SqliteConnection};
use dotenvy::dotenv;
@@ -51,7 +51,17 @@ async fn main() -> std::io::Result<()> {
let cache: util::cache::VideoCache = crate::util::cache::VideoCache::new();
providers::init_providers_now();
thread::spawn(move || {
// Create a tiny runtime just for these async tasks
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("build tokio runtime");
rt.block_on(async move {
providers::init_providers_now();
});
});
web::HttpServer::new(move || {
web::App::new()