diff --git a/Cargo.lock b/Cargo.lock index c43f40a..a5355d6 100644 Binary files a/Cargo.lock and b/Cargo.lock differ diff --git a/emgauwa-controller/Cargo.toml b/emgauwa-controller/Cargo.toml index 26d5a6d..4feb00a 100644 --- a/emgauwa-controller/Cargo.toml +++ b/emgauwa-controller/Cargo.toml @@ -10,9 +10,9 @@ emgauwa-lib = { path = "../emgauwa-lib" } actix = "0.13" tokio = { version = "1.34", features = ["io-std", "macros", "rt-multi-thread"] } -tokio-tungstenite = "0.20" +tokio-tungstenite = "0.21" -simple_logger = "4.2" +simple_logger = "4.3" log = "0.4" chrono = { version = "0.4", features = ["serde"] } diff --git a/emgauwa-controller/src/main.rs b/emgauwa-controller/src/main.rs index 600e924..119b69c 100644 --- a/emgauwa-controller/src/main.rs +++ b/emgauwa-controller/src/main.rs @@ -112,10 +112,10 @@ async fn main() -> Result<(), std::io::Error> { ); - tokio::select! { - _ = run_relays_loop(app_state.clone()) => {}, - _ = run_ws_loop(pool.clone(), app_state.clone(), url) => {}, - } + let _ = tokio::join!( + tokio::spawn(run_relays_loop(app_state.clone())), + tokio::spawn(run_ws_loop(pool.clone(), app_state.clone(), url)), + ); Ok(()) } diff --git a/emgauwa-core/Cargo.toml b/emgauwa-core/Cargo.toml index db61748..6400d42 100644 --- a/emgauwa-core/Cargo.toml +++ b/emgauwa-core/Cargo.toml @@ -10,7 +10,7 @@ emgauwa-lib = { path = "../emgauwa-lib" } actix = "0.13" actix-web = "4.4" actix-web-actors = "4.2" -actix-cors = "0.6" +actix-cors = "0.7" log = "0.4" @@ -23,4 +23,5 @@ serde_derive = "1.0" sqlx = { version = "0.7", features = ["sqlite", "runtime-tokio", "macros", "chrono"] } -futures = "0.3.29" +futures = "0.3" +tokio = { version = "1.36", features = ["rt", "rt-multi-thread"] } diff --git a/emgauwa-core/src/main.rs b/emgauwa-core/src/main.rs index ba632af..1f3e1dd 100644 --- a/emgauwa-core/src/main.rs +++ b/emgauwa-core/src/main.rs @@ -1,6 +1,6 @@ use std::net::TcpListener; -use actix::Actor; +use actix::{Actor, Arbiter}; use actix_cors::Cors; use actix_web::middleware::TrailingSlash; use actix_web::{middleware, web, App, HttpServer}; @@ -32,7 +32,17 @@ async fn main() -> Result<(), std::io::Error> { .map_err(EmgauwaError::from)?; conn.close().await.map_err(EmgauwaError::from)?; - let app_state = AppState::new(pool.clone()).start(); + let app_state_arbiter = Arbiter::with_tokio_rt(|| { + tokio::runtime::Builder::new_multi_thread() + .worker_threads(2) + .enable_all() + .build() + .unwrap() + }); + let app_state_pool = pool.clone(); + let app_state = Actor::start_in_arbiter(&app_state_arbiter.handle(), move |_| { + AppState::new(app_state_pool.clone()) + }); log::info!( "Starting server on {}:{}",