Provide option to set config file location by env
This commit is contained in:
parent
5aa57864d7
commit
978321b0ce
1 changed files with 4 additions and 1 deletions
|
@ -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<RwLock<QueryResults>>;
|
|||
|
||||
fn main() {
|
||||
System::run(move || {
|
||||
let conf_file_loc =
|
||||
var("ENDSTAT_CONF").unwrap_or_else(|_| String::from("./endstat_conf.ron"));
|
||||
let config = from_str::<Config>(
|
||||
&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();
|
||||
|
|
Loading…
Reference in a new issue