From f80083a51cfd8083ce0445bf9f0d6d4f21cd734f Mon Sep 17 00:00:00 2001 From: Jaypal Mudaliyar <77069644+jaypalmudaliyar24@users.noreply.github.com> Date: Fri, 28 Jun 2024 18:59:42 +0530 Subject: [PATCH] enh: add env variables to get dhall config path --- crates/url_shortner/src/main.rs | 10 +++++----- flake.lock | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/url_shortner/src/main.rs b/crates/url_shortner/src/main.rs index bdef59f..fb2b2e5 100644 --- a/crates/url_shortner/src/main.rs +++ b/crates/url_shortner/src/main.rs @@ -7,10 +7,10 @@ */ use actix_web::{web, App, HttpServer}; -use tracing::error; +use tracing::*; use tracing_actix_web::TracingLogger; -use std::net::Ipv4Addr; +use std::{env::var, net::Ipv4Addr}; use url_shortner::{ domain::api, environment::{AppConfig, AppState}, @@ -31,7 +31,8 @@ fn read_dhall_config(config_path: &str) -> Result { #[actix_web::main] async fn start_server() -> std::io::Result<()> { - let dhall_config_path = "./dhall-configs/dev/url-shortner.dhall".to_string(); + let dhall_config_path = var("DHALL_CONFIG_PATH") + .unwrap_or_else(|_| "./dhall-configs/dev/url-shortner.dhall".to_string()); let app_config: AppConfig = read_dhall_config(&dhall_config_path).unwrap_or_else(|err| { println!("{:?}", err); std::process::exit(1); @@ -42,7 +43,6 @@ async fn start_server() -> std::io::Result<()> { let _guard = setup_tracing(app_config.logger_cfg); std::panic::set_hook(Box::new(|panic_info| { - println!("Panic occurred: {:?}", panic_info); error!("Panic occurred: {:?}", panic_info); })); @@ -51,7 +51,7 @@ async fn start_server() -> std::io::Result<()> { let max_allowed_req_size = app_config.max_allowed_req_size; let app_state = AppState::new(app_config).await; - println!("App state created"); + info!("App state created"); let data = web::Data::new(app_state); diff --git a/flake.lock b/flake.lock index 8cbd7fa..b42a150 100644 --- a/flake.lock +++ b/flake.lock @@ -92,7 +92,7 @@ } }, "nixpkgs-lib": { - "locked": { + "locked": { "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=", "type": "tarball", "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"