From 866613cb33df3d21e64b552e3a9da1f69bd96515 Mon Sep 17 00:00:00 2001 From: Ronan Date: Tue, 17 Sep 2024 10:16:49 +0200 Subject: [PATCH] Update dependencies and database configuration --- Cargo.lock | 1 + Cargo.toml | 1 + db_v2.sqlite3 | Bin 352256 -> 352256 bytes src/database.rs | 7 ++++--- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a007236c..7a210562 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1910,6 +1910,7 @@ dependencies = [ "mac_address", "machine-uid 0.2.0", "minreq", + "num_cpus", "once_cell", "ping", "regex", diff --git a/Cargo.toml b/Cargo.toml index adc50b08..60699f8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ ping = "0.5" sctgdesk-api-server = { git = "https://github.com/sctg-development/sctgdesk-api-server.git", branch = "main" } rocket = { version = "0.5", features = ["json", "secrets"] } +num_cpus = "1.16" [build-dependencies] hbb_common = { path = "libs/hbb_common" } diff --git a/db_v2.sqlite3 b/db_v2.sqlite3 index 1be6846a1049eeb2c48d185ee869676496b8acc2..bec0034503fe353b8962bcbe5d36c9e619449e19 100644 GIT binary patch delta 470 zcmZoTAlh(1bi+ewb_***6DtFg$qQu+n3=gHI2#F)1;-PK{nDKz{IlMgcj;!CFeaz= z5B5wz%)I@BJzH@G zb!SDGN<%;Q@mZoT4rYXIu{%A<=fq)dhiXGh14CUfQZO{KGB5xlbZe_?jSLJ8bwS8X N!O+mk)YQt*5&)4nje-CG delta 467 zcmZoTAlh(1bi+ewc5^FJ11lr5$qQu+m|1f4Criu7qKYL8PA-zsKo-+r(PIhYWM>sN z=FDLh%INa0ol=sPXk=hyqHAEOYiO=ufH2gMX~zD^IAemsubWw8hbTpx3Mw36vDI=)@dU4H_ z$$s+kaIq43L#91fCoe}50)+&JRC<%bHU-9?_hBlxFg>sru=}UF%|TuLTcvsWFG=s$ z;q4#nnShvi`v-fL5BvfG@q21&CMyLxJvtI`Y>$iX_7DCnKi|Vl04ieLAs^xId9VG> zX2y>xwTn(ivb?X#dv3OA{oyOE9^1HAI;u108Cn_`>VlDip^=q=0T7{ETU~2pU}&fd PLS_nvhE}GgR)&@Uuv?KV diff --git a/src/database.rs b/src/database.rs index 5d5ee481..f97ba905 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,4 +1,4 @@ -use hbb_common::{log, ResultType}; +use hbb_common::{log, toml::de, ResultType}; use sqlx::{ sqlite::SqliteConnectOptions, ConnectOptions, Connection, Error as SqlxError, SqliteConnection, }; @@ -50,11 +50,12 @@ impl Database { if !std::path::Path::new(url).exists() { std::fs::File::create(url).ok(); } + let deadpool_default_size = num_cpus::get()*4; // cf: https://docs.rs/deadpool/0.12.1/deadpool/managed/struct.PoolConfig.html#structfield.max_size let n: usize = std::env::var("MAX_DATABASE_CONNECTIONS") - .unwrap_or_else(|_| "1".to_owned()) + .unwrap_or_else(|_| deadpool_default_size.to_string().to_owned()) .parse() .unwrap_or(1); - log::debug!("MAX_DATABASE_CONNECTIONS={}", n); + log::info!("MAX_DATABASE_CONNECTIONS={}", n); let pool = Pool::builder(DbPool { url: url.to_owned(),