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()