run init load in its own thread
This commit is contained in:
12
src/main.rs
12
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();
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user