move some libraries out

This commit is contained in:
mbecker20
2024-06-05 23:44:06 -07:00
parent fa72f2e5ef
commit 1a45fffe75
31 changed files with 429 additions and 121 deletions

12
lib/command/Cargo.toml Normal file
View File

@@ -0,0 +1,12 @@
[package]
name = "command"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
[dependencies]
monitor_client.workspace = true
run_command.workspace = true

29
lib/command/src/lib.rs Normal file
View File

@@ -0,0 +1,29 @@
use monitor_client::entities::{monitor_timestamp, update::Log};
use run_command::{async_run_command, CommandOutput};
pub async fn run_monitor_command(
stage: &str,
command: String,
) -> Log {
let start_ts = monitor_timestamp();
let output = async_run_command(&command).await;
output_into_log(stage, command, start_ts, output)
}
pub fn output_into_log(
stage: &str,
command: String,
start_ts: i64,
output: CommandOutput,
) -> Log {
let success = output.success();
Log {
stage: stage.to_string(),
stdout: output.stdout,
stderr: output.stderr,
command,
success,
start_ts,
end_ts: monitor_timestamp(),
}
}