more improvements
This commit is contained in:
+13
-5
@@ -10,7 +10,7 @@ use std::{
|
||||
sync::{atomic::AtomicBool, mpsc, Arc},
|
||||
};
|
||||
|
||||
use ops_sat_rs::config::{action_err::INVALID_ACTION_ID, STOP_FILE_NAME};
|
||||
use ops_sat_rs::config::{action_err::INVALID_ACTION_ID, HOME_PATH, STOP_FILE_NAME};
|
||||
|
||||
use crate::requests::CompositeRequest;
|
||||
|
||||
@@ -30,13 +30,12 @@ pub struct ExperimentController {
|
||||
|
||||
impl ExperimentController {
|
||||
pub fn new(
|
||||
home_dir: &Path,
|
||||
composite_request_rx: mpsc::Receiver<GenericMessage<CompositeRequest>>,
|
||||
action_reply_tx: mpsc::Sender<GenericMessage<PusActionReply>>,
|
||||
stop_signal: Arc<AtomicBool>,
|
||||
) -> Self {
|
||||
let mut home_path_stop_file = PathBuf::new();
|
||||
home_path_stop_file.push(home_dir);
|
||||
home_path_stop_file.push(HOME_PATH.as_path());
|
||||
home_path_stop_file.push(STOP_FILE_NAME);
|
||||
let mut tmp_path_stop_file = temp_dir();
|
||||
tmp_path_stop_file.push(STOP_FILE_NAME);
|
||||
@@ -107,9 +106,18 @@ impl ExperimentController {
|
||||
let check_at_path = |path: &Path| {
|
||||
if path.exists() {
|
||||
log::warn!(
|
||||
"Detected stop file name at {}. Initiating experiment shutdown",
|
||||
STOP_FILE_NAME
|
||||
"Detected stop file name at {:?}. Initiating experiment shutdown",
|
||||
path
|
||||
);
|
||||
// By default, clear the stop file.
|
||||
let result = std::fs::remove_file(path);
|
||||
if result.is_err() {
|
||||
log::error!(
|
||||
"failed to remove stop file at {:?}: {}",
|
||||
path,
|
||||
result.unwrap_err()
|
||||
);
|
||||
}
|
||||
self.stop_signal
|
||||
.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user