feat: init settings in main fn
This commit is contained in:
parent
e3996134e4
commit
90dabb206d
3 changed files with 3 additions and 4 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -166,7 +166,6 @@ impl Settings {
|
|||
|
||||
let settings = s.build()?.try_deserialize::<Settings>()?;
|
||||
settings.check_url();
|
||||
settings.init();
|
||||
|
||||
Ok(settings)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue