Extract dotenv initialization from init_pool because it affects not only database

This commit is contained in:
Kitaiti Makoto 2021-01-05 13:02:05 +09:00
parent 7f1b33a567
commit 29f2239e3f
1 changed files with 6 additions and 6 deletions

View File

@ -50,12 +50,6 @@ compile_i18n!();
/// Initializes a database pool.
fn init_pool() -> Option<DbPool> {
match dotenv::dotenv() {
Ok(path) => println!("Configuration read from {}", path.display()),
Err(ref e) if e.not_found() => eprintln!("no .env was found"),
e => e.map(|_| ()).unwrap(),
}
let manager = ConnectionManager::<Connection>::new(CONFIG.database_url.as_str());
let mut builder = DbPool::builder()
.connection_customizer(Box::new(PragmaForeignKey))
@ -69,6 +63,12 @@ fn init_pool() -> Option<DbPool> {
}
fn main() {
match dotenv::dotenv() {
Ok(path) => println!("Configuration read from {}", path.display()),
Err(ref e) if e.not_found() => eprintln!("no .env was found"),
e => e.map(|_| ()).unwrap(),
}
App::new("Plume")
.bin_name("plume")
.version(env!("CARGO_PKG_VERSION"))