Browse Source

Add the `--no-pid-file` argument

Fixes #60
pull/62/head
Rodolphe Bréard 3 years ago
parent
commit
2c281d1cc7
  1. 3
      CHANGELOG.md
  2. 7
      acme_common/src/lib.rs
  3. 11
      acmed/src/main.rs
  4. 3
      man/en/acmed.8
  5. 3
      man/en/tacd.8
  6. 11
      tacd/src/main.rs

3
CHANGELOG.md

@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Added
- The `--no-pid-file` argument has been added to ACMEd and tacd.
### Fixed ### Fixed
- An invalid reference in the command line arguments has been fixed. - An invalid reference in the command line arguments has been fixed.

7
acme_common/src/lib.rs

@ -47,9 +47,12 @@ pub fn b64_decode<T: ?Sized + AsRef<[u8]>>(input: &T) -> Result<Vec<u8>, error::
Ok(res) 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 { 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()); exit_match!(daemonize.start());
} else if let Some(f) = pid_file { } else if let Some(f) = pid_file {
exit_match!(write_pid_file(f).map_err(|e| e.prefix(f))); exit_match!(write_pid_file(f).map_err(|e| e.prefix(f)));

11
acmed/src/main.rs

@ -104,7 +104,15 @@ fn main() {
.help("Path to the PID file") .help("Path to the PID file")
.takes_value(true) .takes_value(true)
.value_name("FILE") .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(
Arg::new("root-cert") Arg::new("root-cert")
@ -136,7 +144,6 @@ fn main() {
init_server( init_server(
matches.is_present("foreground"), matches.is_present("foreground"),
matches.value_of("pid-file"), matches.value_of("pid-file"),
DEFAULT_PID_FILE,
); );
let config_file = matches.value_of("config").unwrap_or(DEFAULT_CONFIG_FILE); let config_file = matches.value_of("config").unwrap_or(DEFAULT_CONFIG_FILE);

3
man/en/acmed.8

@ -18,6 +18,7 @@
.Op Fl -log-stderr .Op Fl -log-stderr
.Op Fl -log-syslog .Op Fl -log-syslog
.Op Fl -log-level Ar LEVEL .Op Fl -log-level Ar LEVEL
.Op Fl -no-pid-file
.Op Fl -pid-file Ar FILE .Op Fl -pid-file Ar FILE
.Op Fl -root-cert Ar FILE .Op Fl -root-cert Ar FILE
.Op Fl V|--version .Op Fl V|--version
@ -42,6 +43,8 @@ Prints log messages to the standard error output
Sends log messages via syslog Sends log messages via syslog
.It Fl -log-level Ar LEVEL .It Fl -log-level Ar LEVEL
Specify the log level. Possible values: error, warn, info, debug and trace. 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 .It Fl -pid-file Ar FILE
Specifies the location of the PID file Specifies the location of the PID file
.It Fl -root-cert Ar FILE .It Fl -root-cert Ar FILE

3
man/en/tacd.8

@ -24,6 +24,7 @@
.Op Fl -log-stderr .Op Fl -log-stderr
.Op Fl -log-syslog .Op Fl -log-syslog
.Op Fl -log-level Ar LEVEL .Op Fl -log-level Ar LEVEL
.Op Fl -no-pid-file
.Op Fl -pid-file Ar FILE .Op Fl -pid-file Ar FILE
.Op Fl V|--version .Op Fl V|--version
.Sh DESCRIPTION .Sh DESCRIPTION
@ -81,6 +82,8 @@ Prints log messages to the standard error output.
Sends log messages via syslog. Sends log messages via syslog.
.It Fl -log-level Ar LEVEL .It Fl -log-level Ar LEVEL
Specify the log level. Possible values: error, warn, info, debug and trace. 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 .It Fl -pid-file Ar FILE
Specifies the location of the PID file. Specifies the location of the PID file.
.It Fl V, -version .It Fl V, -version

11
tacd/src/main.rs

@ -48,7 +48,6 @@ fn init(cnf: &ArgMatches) -> Result<(), Error> {
acme_common::init_server( acme_common::init_server(
cnf.is_present("foreground"), cnf.is_present("foreground"),
cnf.value_of("pid-file"), cnf.value_of("pid-file"),
DEFAULT_PID_FILE,
); );
let domain = get_acme_value(cnf, "domain", "domain-file")?; let domain = get_acme_value(cnf, "domain", "domain-file")?;
let domain = to_idna(&domain)?; let domain = to_idna(&domain)?;
@ -176,7 +175,15 @@ fn main() {
.help("Path to the PID file") .help("Path to the PID file")
.takes_value(true) .takes_value(true)
.value_name("FILE") .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(); .get_matches();

Loading…
Cancel
Save