Skip to content

Commit

Permalink
Add default input functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mzhong1 committed Dec 17, 2019
1 parent 768e528 commit 08093a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
19 changes: 16 additions & 3 deletions src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ pub fn remove_disk_request(
}
}

// default filename for daemon_output
fn default_out() -> String {
"bynar_daemon.out".to_string()
}
// default filename for daemon_err
fn default_err() -> String {
"bynar_daemon.err".to_string()
}
//default filename for daemon_pid
fn default_pid() -> String {
"bynar_daemon.pid".to_string()
}

#[derive(Clone, Debug, Deserialize)]
pub struct ConfigSettings {
pub manager_host: String,
Expand All @@ -227,13 +240,13 @@ pub struct ConfigSettings {
pub jira_project_id: String,
pub jira_ticket_assignee: String,
/// Name of the Daemon Output file
#[serde(default = "bynar_daemon.out")]
#[serde(default = "default_out")]
pub daemon_output: String,
/// Name of the Daemon Error file
#[serde(default = "bynar_daemon.err")]
#[serde(default = "default_err")]
pub daemon_error: String,
/// Name of the Daemon pid file
#[serde(default = "bynar_daemon.pid")]
#[serde(default = "default_pid")]
pub daemon_pid: String,
pub proxy: Option<String>,
pub database: DBConfig,
Expand Down
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,8 @@ fn main() {
let outfile = format!("/var/log/{}", config.daemon_output);
let errfile = format!("/var/log/{}", config.daemon_error);
let pidfile = format!("/var/log/{}", config.daemon_pid);
let stdout = File::create(&outfile)
.expect(&format!("{} creation failed", outfile));
let stderr = File::create(&errfile)
.expect(&format!("{} creation failed", errfile));
let stdout = File::create(&outfile).expect(&format!("{} creation failed", outfile));
let stderr = File::create(&errfile).expect(&format!("{} creation failed", errfile));

trace!("I'm Parent and My pid is {}", process::id());

Expand All @@ -601,7 +599,6 @@ fn main() {
}
info!("Starting up");


let simulate = matches.is_present("simulate");
let time = matches.value_of("time").unwrap().parse::<u64>().unwrap();
let h_info = Host::new();
Expand All @@ -612,7 +609,6 @@ fn main() {
}
let host_info = h_info.expect("Failed to gather host information");
debug!("Gathered host info: {:?}", host_info);


let db_pool = match create_db_connection_pool(&config.database) {
Err(e) => {
Expand Down

0 comments on commit 08093a1

Please sign in to comment.