diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 10 | 
1 files changed, 6 insertions, 4 deletions
| diff --git a/src/main.rs b/src/main.rs index bc9a7b5..cf451dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,11 +3,11 @@  // TODO: Log levels -use std::{path::PathBuf, process::Stdio}; +use std::{path::PathBuf, process::Stdio, time::Duration};  use anyhow::Context;  use rumqttc::{Event::Incoming, Packet, Publish, QoS}; -use tokio::{io::AsyncWriteExt, process::Command}; +use tokio::{io::AsyncWriteExt, process::Command, time::timeout};  mod config; @@ -87,8 +87,10 @@ async fn main() -> anyhow::Result<()> {                          let program = program.clone();                          let p = p.clone();                          tokio::spawn(async move { -                            if let Err(e) = run(&program, &p).await { -                                eprintln!("error: Failed to run {program:?}: {e:?}"); +                            match timeout(Duration::from_secs(60), run(&program, &p)).await { +                                Err(_) => eprintln!("error: Execution of {program:?} for message {p:?} timed out"), +                                Ok(Err(e)) => eprintln!("error: Failed to run {program:?}: {e:?}"), +                                _ => (),                              }                          });                      } | 
