Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic on executing command directly #159

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use tokio::{
use crate::{
action::Action,
bytes::normalize_stdout,
components::status,
config::{Config, RuntimeConfig},
exec::exec,
store::{Record, Store},
Expand Down Expand Up @@ -39,12 +40,11 @@ pub async fn run_executor<S: Store>(
}

let result = exec(runtime_config.command.clone(), shell.clone()).await;
if result.is_err() {
eprintln!("Failed to execute command");
tokio::time::sleep(runtime_config.interval.to_std().unwrap()).await;
}
let (stdout, stderr, status) = match result {
Ok(result) => result,
Err(e) => (vec![], e.to_string().bytes().collect(), 1),
};

let (stdout, stderr, status) = result.unwrap();
let exit_code = status;
let utf8_stdout = String::from_utf8_lossy(&stdout).to_string();
let utf8_stderr = String::from_utf8_lossy(&stderr).to_string();
Expand Down Expand Up @@ -113,12 +113,11 @@ pub async fn run_executor_precise<S: Store>(
}

let result = exec(runtime_config.command.clone(), shell.clone()).await;
if result.is_err() {
eprintln!("Failed to execute command");
tokio::time::sleep(runtime_config.interval.to_std().unwrap()).await;
}
let (stdout, stderr, status) = match result {
Ok(result) => result,
Err(e) => (vec![], e.to_string().bytes().collect(), 1),
};

let (stdout, stderr, status) = result.unwrap();
let exit_code = status;
let utf8_stdout = String::from_utf8_lossy(&stdout).to_string();
let utf8_stderr = String::from_utf8_lossy(&stderr).to_string();
Expand Down