diff --git a/CHANGELOG.md b/CHANGELOG.md index 8af41e2..5f50193 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- The `--no-pid-file` argument has been added to ACMEd and tacd. + ### Fixed - An invalid reference in the command line arguments has been fixed. diff --git a/acme_common/src/lib.rs b/acme_common/src/lib.rs index 657f621..c3240da 100644 --- a/acme_common/src/lib.rs +++ b/acme_common/src/lib.rs @@ -47,9 +47,12 @@ pub fn b64_decode>(input: &T) -> Result, error:: Ok(res) } -pub fn init_server(foreground: bool, pid_file: Option<&str>, default_pid_file: &str) { +pub fn init_server(foreground: bool, pid_file: Option<&str>) { if !foreground { - let daemonize = Daemonize::new().pid_file(pid_file.unwrap_or(default_pid_file)); + let mut daemonize = Daemonize::new(); + if let Some(f) = pid_file { + daemonize = daemonize.pid_file(f); + } exit_match!(daemonize.start()); } else if let Some(f) = pid_file { exit_match!(write_pid_file(f).map_err(|e| e.prefix(f))); diff --git a/acmed/src/main.rs b/acmed/src/main.rs index e201b54..56ab66b 100644 --- a/acmed/src/main.rs +++ b/acmed/src/main.rs @@ -104,7 +104,15 @@ fn main() { .help("Path to the PID file") .takes_value(true) .value_name("FILE") - .default_value(DEFAULT_PID_FILE), + .default_value(DEFAULT_PID_FILE) + .default_value_if("no-pid-file", None, None) + .conflicts_with("no-pid-file"), + ) + .arg( + Arg::new("no-pid-file") + .long("no-pid-file") + .help("Do not create any PID file") + .conflicts_with("pid-file"), ) .arg( Arg::new("root-cert") @@ -136,7 +144,6 @@ fn main() { init_server( matches.is_present("foreground"), matches.value_of("pid-file"), - DEFAULT_PID_FILE, ); let config_file = matches.value_of("config").unwrap_or(DEFAULT_CONFIG_FILE); diff --git a/man/en/acmed.8 b/man/en/acmed.8 index 7b61fa1..c5a8d1c 100644 --- a/man/en/acmed.8 +++ b/man/en/acmed.8 @@ -18,6 +18,7 @@ .Op Fl -log-stderr .Op Fl -log-syslog .Op Fl -log-level Ar LEVEL +.Op Fl -no-pid-file .Op Fl -pid-file Ar FILE .Op Fl -root-cert Ar FILE .Op Fl V|--version @@ -42,6 +43,8 @@ Prints log messages to the standard error output Sends log messages via syslog .It Fl -log-level Ar LEVEL Specify the log level. Possible values: error, warn, info, debug and trace. +.It Fl -no-pid-file +Do not create any PID file .It Fl -pid-file Ar FILE Specifies the location of the PID file .It Fl -root-cert Ar FILE diff --git a/man/en/tacd.8 b/man/en/tacd.8 index 8b3dd0b..05b5dbc 100644 --- a/man/en/tacd.8 +++ b/man/en/tacd.8 @@ -24,6 +24,7 @@ .Op Fl -log-stderr .Op Fl -log-syslog .Op Fl -log-level Ar LEVEL +.Op Fl -no-pid-file .Op Fl -pid-file Ar FILE .Op Fl V|--version .Sh DESCRIPTION @@ -81,6 +82,8 @@ Prints log messages to the standard error output. Sends log messages via syslog. .It Fl -log-level Ar LEVEL Specify the log level. Possible values: error, warn, info, debug and trace. +.It Fl -no-pid-file +Do not create any PID file .It Fl -pid-file Ar FILE Specifies the location of the PID file. .It Fl V, -version diff --git a/tacd/src/main.rs b/tacd/src/main.rs index 2f68dfa..b3de330 100644 --- a/tacd/src/main.rs +++ b/tacd/src/main.rs @@ -48,7 +48,6 @@ fn init(cnf: &ArgMatches) -> Result<(), Error> { acme_common::init_server( cnf.is_present("foreground"), cnf.value_of("pid-file"), - DEFAULT_PID_FILE, ); let domain = get_acme_value(cnf, "domain", "domain-file")?; let domain = to_idna(&domain)?; @@ -176,7 +175,15 @@ fn main() { .help("Path to the PID file") .takes_value(true) .value_name("FILE") - .default_value(DEFAULT_PID_FILE), + .default_value(DEFAULT_PID_FILE) + .default_value_if("no-pid-file", None, None) + .conflicts_with("no-pid-file"), + ) + .arg( + Arg::new("no-pid-file") + .long("no-pid-file") + .help("Do not create any PID file") + .conflicts_with("pid-file"), ) .get_matches();