diff --git a/acme_common/src/lib.rs b/acme_common/src/lib.rs index 0e6b3aa..8578322 100644 --- a/acme_common/src/lib.rs +++ b/acme_common/src/lib.rs @@ -40,12 +40,12 @@ pub fn b64_encode>(input: &T) -> String { base64::encode_config(input, base64::URL_SAFE_NO_PAD) } -pub fn init_server(foreground: bool, pid_file: &str) { +pub fn init_server(foreground: bool, pid_file: Option<&str>, default_pid_file: &str) { if !foreground { - let daemonize = Daemonize::new().pid_file(pid_file); + let daemonize = Daemonize::new().pid_file(pid_file.unwrap_or(default_pid_file)); exit_match!(daemonize.start()); - } else { - exit_match!(write_pid_file(pid_file)); + } else if let Some(f) = pid_file { + exit_match!(write_pid_file(f)); } } diff --git a/acmed/src/main.rs b/acmed/src/main.rs index 01c3ccb..87c4660 100644 --- a/acmed/src/main.rs +++ b/acmed/src/main.rs @@ -117,7 +117,8 @@ fn main() { init_server( matches.is_present("foreground"), - matches.value_of("pid-file").unwrap_or(DEFAULT_PID_FILE), + matches.value_of("pid-file"), + DEFAULT_PID_FILE, ); let config_file = matches.value_of("config").unwrap_or(DEFAULT_CONFIG_FILE); diff --git a/tacd/src/main.rs b/tacd/src/main.rs index b0d63eb..1f59982 100644 --- a/tacd/src/main.rs +++ b/tacd/src/main.rs @@ -42,7 +42,8 @@ fn get_acme_value(cnf: &ArgMatches, opt: &str, opt_file: &str) -> Result Result<(), Error> { acme_common::init_server( cnf.is_present("foreground"), - cnf.value_of("pid-file").unwrap_or(DEFAULT_PID_FILE), + cnf.value_of("pid-file"), + DEFAULT_PID_FILE, ); let domain = get_acme_value(cnf, "domain", "domain-file")?; let domain = to_idna(&domain)?;