feat: init settings in main fn

This commit is contained in:
Aravinth Manivannan 2022-09-16 13:22:29 +05:30
parent e3996134e4
commit 90dabb206d
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
3 changed files with 3 additions and 4 deletions

View File

@ -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;

View File

@ -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

View File

@ -166,7 +166,6 @@ impl Settings {
let settings = s.build()?.try_deserialize::<Settings>()?;
settings.check_url();
settings.init();
Ok(settings)
}