diff --git a/crates/openshell-server/src/persistence/postgres.rs b/crates/openshell-server/src/persistence/postgres.rs index 4b62516c..c6f82a58 100644 --- a/crates/openshell-server/src/persistence/postgres.rs +++ b/crates/openshell-server/src/persistence/postgres.rs @@ -18,6 +18,9 @@ impl PostgresStore { pub async fn connect(url: &str) -> Result { let pool = PgPoolOptions::new() .max_connections(10) + .acquire_timeout(std::time::Duration::from_secs(5)) + .idle_timeout(std::time::Duration::from_secs(300)) + .max_lifetime(std::time::Duration::from_secs(1800)) .connect(url) .await .map_err(|e| map_db_error(&e))?; diff --git a/crates/openshell-server/src/persistence/sqlite.rs b/crates/openshell-server/src/persistence/sqlite.rs index 167f3521..4d34e933 100644 --- a/crates/openshell-server/src/persistence/sqlite.rs +++ b/crates/openshell-server/src/persistence/sqlite.rs @@ -30,6 +30,9 @@ impl SqliteStore { let pool = SqlitePoolOptions::new() .max_connections(max_connections) .min_connections(max_connections) + .acquire_timeout(std::time::Duration::from_secs(5)) + .idle_timeout(std::time::Duration::from_secs(300)) + .max_lifetime(std::time::Duration::from_secs(1800)) .connect_with(options) .await .map_err(|e| map_db_error(&e))?;