Skip to content

Commit

Permalink
Merge pull request #159 from sachaos/fix-panic-bug
Browse files Browse the repository at this point in the history
Fix panic on executing command directly
  • Loading branch information
sachaos authored Oct 4, 2024
2 parents e700171 + ac98234 commit c42e6ad
Showing 1 changed file with 9 additions and 10 deletions.
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

0 comments on commit c42e6ad

Please sign in to comment.