From abf0b28fd440bee47b3c288ff81ee1e1db51e57a Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 15 Jan 2023 06:07:24 +0900 Subject: [PATCH] Move set up from init_rocket() to main() --- src/main.rs | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5e3c0e78..33ada0a5 100755 --- a/src/main.rs +++ b/src/main.rs @@ -64,26 +64,6 @@ fn init_pool() -> Option { } pub(crate) fn init_rocket() -> rocket::Rocket { - match dotenv::dotenv() { - Ok(path) => eprintln!("Configuration read from {}", path.display()), - Err(ref e) if e.not_found() => eprintln!("no .env was found"), - e => e.map(|_| ()).unwrap(), - } - tracing_subscriber::fmt::init(); - - App::new("Plume") - .bin_name("plume") - .version(env!("CARGO_PKG_VERSION")) - .about("Plume backend server") - .after_help( - r#" -The plume command should be run inside the directory -containing the `.env` configuration file and `static` directory. -See https://docs.joinplu.me/installation/config -and https://docs.joinplu.me/installation/init for more info. - "#, - ) - .get_matches(); let dbpool = init_pool().expect("main: database pool initialization error"); if IMPORTED_MIGRATIONS .is_pending(&dbpool.get().unwrap()) @@ -280,6 +260,27 @@ Then try to restart Plume. } fn main() { + match dotenv::dotenv() { + Ok(path) => eprintln!("Configuration read from {}", path.display()), + Err(ref e) if e.not_found() => eprintln!("no .env was found"), + e => e.map(|_| ()).unwrap(), + } + tracing_subscriber::fmt::init(); + + App::new("Plume") + .bin_name("plume") + .version(env!("CARGO_PKG_VERSION")) + .about("Plume backend server") + .after_help( + r#" +The plume command should be run inside the directory +containing the `.env` configuration file and `static` directory. +See https://docs.joinplu.me/installation/config +and https://docs.joinplu.me/installation/init for more info. + "#, + ) + .get_matches(); + let rocket = init_rocket(); #[cfg(feature = "test")]