Skip to content

Commit

Permalink
enh: add env variables to get dhall config path
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypalmudaliyar24 committed Jun 28, 2024
1 parent 3cb4b49 commit f80083a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions crates/url_shortner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -31,7 +31,8 @@ fn read_dhall_config(config_path: &str) -> Result<AppConfig, String> {

#[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);
Expand All @@ -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);
}));

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f80083a

Please sign in to comment.