From ef424cf070d070cc1efb975354cbc48036b9bbdb Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 30 Oct 2021 15:37:24 +0530 Subject: [PATCH] make repository updates non-blocking --- src/deploy.rs | 6 +++++- src/main.rs | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/deploy.rs b/src/deploy.rs index 71a1792..91690bc 100644 --- a/src/deploy.rs +++ b/src/deploy.rs @@ -44,7 +44,11 @@ async fn update(payload: web::Json) -> impl Responder { let mut found = false; for page in SETTINGS.pages.iter() { if page.secret == payload.secret { - page.fetch_upstream(&page.branch); + web::block(|| { + page.fetch_upstream(&page.branch); + }) + .await + .unwrap(); found = true; } } diff --git a/src/main.rs b/src/main.rs index 21911ca..7d7a679 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,9 +71,8 @@ async fn main() -> std::io::Result<()> { actix_middleware::TrailingSlash::Trim, )) .configure(services) - // .app_data(data.clone()) }) - .workers(SETTINGS.server.workers.unwrap_or(num_cpus::get())) + .workers(SETTINGS.server.workers.unwrap_or_else(num_cpus::get)) .bind(SETTINGS.server.get_ip()) .unwrap() .run()