run init load in its own thread
This commit is contained in:
14
src/main.rs
14
src/main.rs
@@ -2,7 +2,7 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
|
|
||||||
use std::env;
|
use std::{env, thread};
|
||||||
|
|
||||||
use diesel::{r2d2::{self, ConnectionManager}, SqliteConnection};
|
use diesel::{r2d2::{self, ConnectionManager}, SqliteConnection};
|
||||||
use dotenvy::dotenv;
|
use dotenvy::dotenv;
|
||||||
@@ -51,7 +51,17 @@ async fn main() -> std::io::Result<()> {
|
|||||||
|
|
||||||
let cache: util::cache::VideoCache = crate::util::cache::VideoCache::new();
|
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::HttpServer::new(move || {
|
||||||
web::App::new()
|
web::App::new()
|
||||||
|
|||||||
Reference in New Issue
Block a user