mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-09 18:25:58 +03:00
refactor(config): update template, add validation (#6229)
This change is a follow up to #6166 - add new options to `.env.template` - add validation for new config option values
This commit is contained in:
committed by
GitHub
parent
5ee908517f
commit
7161f612a1
@@ -80,8 +80,16 @@
|
|||||||
## Timeout when acquiring database connection
|
## Timeout when acquiring database connection
|
||||||
# DATABASE_TIMEOUT=30
|
# DATABASE_TIMEOUT=30
|
||||||
|
|
||||||
|
## Database idle timeout
|
||||||
|
## Timeout in seconds before idle connections to the database are closed.
|
||||||
|
# DATABASE_IDLE_TIMEOUT=600
|
||||||
|
|
||||||
|
## Database min connections
|
||||||
|
## Define the minimum size of the connection pool used for connecting to the database.
|
||||||
|
# DATABASE_MIN_CONNS=2
|
||||||
|
|
||||||
## Database max connections
|
## Database max connections
|
||||||
## Define the size of the connection pool used for connecting to the database.
|
## Define the maximum size of the connection pool used for connecting to the database.
|
||||||
# DATABASE_MAX_CONNS=10
|
# DATABASE_MAX_CONNS=10
|
||||||
|
|
||||||
## Database connection initialization
|
## Database connection initialization
|
||||||
|
@@ -834,6 +834,14 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
|
|||||||
err!(format!("`DATABASE_MAX_CONNS` contains an invalid value. Ensure it is between 1 and {limit}.",));
|
err!(format!("`DATABASE_MAX_CONNS` contains an invalid value. Ensure it is between 1 and {limit}.",));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.database_min_conns < 1 || cfg.database_min_conns > limit {
|
||||||
|
err!(format!("`DATABASE_MIN_CONNS` contains an invalid value. Ensure it is between 1 and {limit}.",));
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.database_min_conns > cfg.database_max_conns {
|
||||||
|
err!(format!("`DATABASE_MIN_CONNS` must be smaller than or equal to `DATABASE_MAX_CONNS`.",));
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(log_file) = &cfg.log_file {
|
if let Some(log_file) = &cfg.log_file {
|
||||||
if std::fs::OpenOptions::new().append(true).create(true).open(log_file).is_err() {
|
if std::fs::OpenOptions::new().append(true).create(true).open(log_file).is_err() {
|
||||||
err!("Unable to write to log file", log_file);
|
err!("Unable to write to log file", log_file);
|
||||||
|
Reference in New Issue
Block a user