From 978321b0cec54421df222c342f982e95cc66cd43 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Thu, 2 May 2019 00:02:53 -0400 Subject: [PATCH] Provide option to set config file location by env --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a50535a..94154ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,7 @@ use actix_web::{middleware::Logger, web::resource, App, HttpServer}; use chrono::prelude::*; use ron::de::from_str; use std::{ + env::var, fs::read_to_string, sync::{Arc, RwLock}, time::Duration, @@ -32,8 +33,10 @@ pub type State = Arc>; fn main() { System::run(move || { + let conf_file_loc = + var("ENDSTAT_CONF").unwrap_or_else(|_| String::from("./endstat_conf.ron")); let config = from_str::( - &read_to_string("./endstat_conf.ron").expect("finding ./endstat_conf.ron"), + &read_to_string(&conf_file_loc).expect(&format!("finding {}", conf_file_loc)), ) .unwrap(); let bind_addr = config.bind_address.clone();