fix: loading sqlite database URL from env var
SUMMARY sqlite caused problems(panic) when trying to break its database URL when trying to break it down into host, protocol, path and port, etc. with crate::settings;:DatabaseBuilder. Bypassing DatabaseBuilder and directly setting crate::settings::Database.url, fixes this issue.
This commit is contained in:
parent
ea0e299fef
commit
b39ce2098a
1 changed files with 6 additions and 5 deletions
|
@ -215,14 +215,15 @@ impl Settings {
|
||||||
match env::var("DATABASE_URL") {
|
match env::var("DATABASE_URL") {
|
||||||
Ok(val) => {
|
Ok(val) => {
|
||||||
let url = Url::parse(&val).expect("couldn't parse Database URL");
|
let url = Url::parse(&val).expect("couldn't parse Database URL");
|
||||||
let database_conf = DatabaseBuilder::extract_database_url(&url);
|
s.set("database.url", url.to_string())
|
||||||
set_from_database_url(&mut s, &database_conf);
|
.expect("unable to set database URL");
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
warn!("couldn't interpret DATABASE_URL: {}", e);
|
||||||
|
set_database_url(&mut s);
|
||||||
}
|
}
|
||||||
Err(e) => warn!("couldn't interpret DATABASE_URL: {}", e),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_database_url(&mut s);
|
|
||||||
|
|
||||||
let mut settings: Settings = s.try_into()?;
|
let mut settings: Settings = s.try_into()?;
|
||||||
|
|
||||||
settings.log.set_log_level();
|
settings.log.set_log_level();
|
||||||
|
|
Loading…
Reference in a new issue