From 90dabb206dcd30687e8675afd1bf81f706b259bb Mon Sep 17 00:00:00 2001 From: realaravinth Date: Fri, 16 Sep 2022 13:22:29 +0530 Subject: [PATCH] feat: init settings in main fn --- src/errors.rs | 1 - src/main.rs | 5 +++-- src/settings.rs | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 9ee5433..3a07299 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -16,7 +16,6 @@ */ //! Represents all the ways a trait can fail using this crate use std::convert::From; -use std::error::Error as StdError; use std::io::Error as FSErrorInner; use std::sync::Arc; diff --git a/src/main.rs b/src/main.rs index 0579a7d..7a73ff6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -108,6 +108,7 @@ async fn main() -> std::io::Result<()> { ); let settings = Settings::new().unwrap(); + settings.init(); let ctx = Ctx::new(settings.clone()).await; let ctx = actix_web::web::Data::new(ctx); @@ -121,7 +122,7 @@ async fn main() -> std::io::Result<()> { async fn serve(settings: Settings, ctx: AppCtx) -> std::io::Result<()> { let ip = settings.server.get_ip(); - info!("Starting server on: http://{}", settings.server.get_ip()); + info!("Starting server on: http://{}", ip); HttpServer::new(move || { App::new() .wrap(actix_middleware::Logger::default()) @@ -138,7 +139,7 @@ async fn serve(settings: Settings, ctx: AppCtx) -> std::io::Result<()> { .configure(services) }) .workers(settings.server.workers.unwrap_or_else(num_cpus::get)) - .bind(settings.server.get_ip()) + .bind(ip) .unwrap() .run() .await diff --git a/src/settings.rs b/src/settings.rs index c4f57fa..1cb0290 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -166,7 +166,6 @@ impl Settings { let settings = s.build()?.try_deserialize::()?; settings.check_url(); - settings.init(); Ok(settings) }