-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from tmknight/develop
v0.9.0
- Loading branch information
Showing
9 changed files
with
190 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use crate::{report::logging::log_message, ERROR, INFO}; | ||
use std::fs; | ||
use std::process::Command; | ||
|
||
pub async fn execute_action(post_action: String, name: &str, id: String, timeout: String) { | ||
// Check if the script exists | ||
if fs::metadata(post_action.clone()).is_ok() { | ||
// Execute using Command | ||
let mut command = Command::new(post_action.clone()); | ||
|
||
// Arguments to the command | ||
command.args([name, &id, &timeout]); | ||
|
||
// Execute the command and handle the result | ||
let msg0 = match command.spawn() { | ||
Ok(mut child) => { | ||
// Wait for the child process to finish | ||
match child.wait() { | ||
Ok(_s) => format!( | ||
"[{}] Post-action ({}) for container ({}) was successful", | ||
name, post_action, id | ||
), | ||
Err(e) => format!( | ||
"[{}] Post-action ({}) for container ({}) failed to complete: {}", | ||
name, post_action, id, e | ||
), | ||
} | ||
} | ||
Err(e) => format!( | ||
"[{}] Post-action ({}) for container ({}) failed to start: {}", | ||
name, post_action, id, e | ||
), | ||
}; | ||
log_message(&msg0, INFO).await; | ||
} else { | ||
let msg0 = format!( | ||
"[{}] Post-action ({}) for container ({}) not found", | ||
name, post_action, id | ||
); | ||
log_message(&msg0, ERROR).await; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.