Load defaults from environment variables
This commit is contained in:
parent
33fa4bd266
commit
43e97d4db7
18
src/conf.rs
18
src/conf.rs
|
@ -17,10 +17,22 @@ impl Conf {
|
||||||
Err(_) => "http://localhost:4444".to_string(),
|
Err(_) => "http://localhost:4444".to_string(),
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
};
|
};
|
||||||
|
let default_job_dir = match std::env::var("HAUNTER_JOBS_DIR") {
|
||||||
|
Err(_) => PathBuf::from("jobs.d".to_string()),
|
||||||
|
Ok(v) => PathBuf::from(v),
|
||||||
|
};
|
||||||
|
let default_results_dir = match std::env::var("HAUNTER_RESULTS_DIR") {
|
||||||
|
Err(_) => PathBuf::from("results.d".to_string()),
|
||||||
|
Ok(v) => PathBuf::from(v),
|
||||||
|
};
|
||||||
|
let default_interval = match std::env::var("HAUNTER_DEFAULT_INTERVAL") {
|
||||||
|
Err(_) => Duration::new(15*60, 0),
|
||||||
|
Ok(v) => Duration::new(v.parse::<u64>().unwrap(), 0),
|
||||||
|
};
|
||||||
return Conf {
|
return Conf {
|
||||||
job_dir: PathBuf::from_str("jobs.d").unwrap(),
|
job_dir: default_job_dir,
|
||||||
output_dir: PathBuf::from_str("results.d").unwrap(),
|
output_dir: default_results_dir,
|
||||||
check_interval: Duration::new(15*60, 0),
|
check_interval: default_interval,
|
||||||
driver_url: default_driver_url,
|
driver_url: default_driver_url,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue