Make data dir lock opt-in (#856)

This commit is contained in:
Tim Bruijnzeels
2022-07-25 10:35:28 -04:00
parent 7675a5352a
commit 6ff84db232
2 changed files with 22 additions and 9 deletions
+5
View File
@@ -372,6 +372,9 @@ pub struct Config {
#[serde(default = "ConfigDefaults::data_dir")]
pub data_dir: PathBuf,
#[serde(default)] // default is false
pub data_dir_use_lock: bool,
#[serde(default = "ConfigDefaults::always_recover_data")]
pub always_recover_data: bool,
@@ -783,6 +786,7 @@ impl Config {
let https_mode = HttpsMode::Generate;
let data_dir = data_dir.to_path_buf();
let data_dir_use_lock = true; // ensure we touch this in tests
let always_recover_data = false;
let log_level = LevelFilter::Debug;
@@ -903,6 +907,7 @@ impl Config {
port,
https_mode,
data_dir,
data_dir_use_lock,
always_recover_data,
pid_file,
service_uri: None,
+17 -9
View File
@@ -113,7 +113,11 @@ fn test_data_dirs_or_die(config: &Config) {
}
pub async fn start_krill_daemon(config: Arc<Config>) -> Result<(), Error> {
let lock = KrillLock::create(&config);
let optional_lock = if config.data_dir_use_lock {
Some(KrillLock::create(&config))
} else {
None
};
write_pid_file_or_die(&config);
test_data_dirs_or_die(&config);
@@ -187,14 +191,18 @@ pub async fn start_krill_daemon(config: Arc<Config>) -> Result<(), Error> {
let scheduler_task = scheduler.run();
try_join!(
server,
scheduler_task,
lock.handle_ctrl_c(),
#[cfg(unix)]
lock.handle_sig_term()
)
.map(|_| ())
if let Some(lock) = optional_lock {
try_join!(
server,
scheduler_task,
lock.handle_ctrl_c(),
#[cfg(unix)]
lock.handle_sig_term()
)
.map(|_| ())
} else {
try_join!(server, scheduler_task,).map(|_| ())
}
}
struct RequestLogger {