Skip to content

Commit

Permalink
Update dependencies and database configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
eltorio committed Sep 17, 2024
1 parent bf312da commit 866613c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Binary file modified db_v2.sqlite3
Binary file not shown.
7 changes: 4 additions & 3 deletions src/database.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 866613c

Please sign in to comment.