Add daemon CLI commands
- Introduce option `--background` for `daemon start` to send the new process into the background. - Implement a `ProcessDescr` which identifies a Husk process. This pays attention to the possibility of a rollover of the process ids. - Implement `daemon status`. - Implement `daemon stop` which sends `SIG_INT` to a running Husk process.
This commit is contained in:
+13
-2
@@ -9,7 +9,9 @@ use toml;
|
||||
use log4rs;
|
||||
|
||||
use crate::types::errors::HuskError;
|
||||
use crate::types::defaults::{CONSOLE_LOGGING, SUBJECT_REPLACEMENT};
|
||||
use crate::types::defaults::CONSOLE_LOGGING;
|
||||
use crate::types::defaults::PID_FILE_LOCATION;
|
||||
use crate::types::defaults::SUBJECT_REPLACEMENT;
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
pub struct HuskConfig {
|
||||
@@ -17,6 +19,7 @@ pub struct HuskConfig {
|
||||
pub sequoia_home: String,
|
||||
pub keyservers: Option<Vec<String>>,
|
||||
pub subject_replacement: Option<String>,
|
||||
pub pid_file: Option<String>,
|
||||
logging: Option<toml::Value>,
|
||||
}
|
||||
|
||||
@@ -76,6 +79,13 @@ impl HuskConfig {
|
||||
SUBJECT_REPLACEMENT.to_string()
|
||||
}
|
||||
}
|
||||
pub fn get_pid_file(&self) -> String {
|
||||
if let Some(pid_file) = &self.pid_file {
|
||||
pid_file.clone()
|
||||
} else {
|
||||
PID_FILE_LOCATION.to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type HuskConfigContainer = Arc<Mutex<HuskConfig>>;
|
||||
@@ -101,7 +111,8 @@ mod tests {
|
||||
sequoia_home: "".into(),
|
||||
keyservers: None,
|
||||
subject_replacement: None,
|
||||
logging: None
|
||||
logging: None,
|
||||
pid_file: None,
|
||||
};
|
||||
|
||||
assert_eq!(config.get_subject_replacement(), defaults::SUBJECT_REPLACEMENT);
|
||||
|
||||
Reference in New Issue
Block a user