From 9e30eedc776276eb37abd5c1e3ead1f8ab6002ad Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 4 Dec 2025 13:11:46 +0000 Subject: [PATCH] run init load in its own thread --- src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8c2a952..bfdc97b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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()