From c959da7011aebdb92a55a3e872c07e2727ccf11d Mon Sep 17 00:00:00 2001 From: Kasper Seweryn Date: Mon, 4 Nov 2024 13:42:18 +0100 Subject: [PATCH] feat: crash app with entire stack trace --- src/main.rs | 48 +++++++++---------------------------------- src/tasks/factorio.rs | 14 ++++++------- 2 files changed, 17 insertions(+), 45 deletions(-) diff --git a/src/main.rs b/src/main.rs index a0dbeb5..3e6ada8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,8 @@ async fn main() -> Result<()> { color_eyre::install()?; tracing_subscriber::fmt::init(); + info!("Cracktorio bot started"); + let (tx, rx) = mpsc::channel::(1); let scrapper = tasks::scrapper::run(tx.clone()); @@ -28,51 +30,21 @@ async fn main() -> Result<()> { tokio::select! { _ = tokio::signal::ctrl_c() => { info!("Shutting down..."); }, result = tokio::spawn(scrapper) => { - match result { - Err(e) => { - error!("Scrapper task failed: {}", e); - } - Ok(()) => { - info!("Scrapper task finished"); - } - } + info!("Scrapper task finished"); + result?; }, result = tokio::spawn(factorio) => { - match result { - Err(e) => { - error!("Factorio log reading task failed: {}", e); - } - Ok(Err(e)) => { - error!("Factorio log reading task failed: {}", e); - } - Ok(Ok(())) => { - info!("Factorio log reading task finished"); - } - } + info!("Factorio log reading task finished"); + result??; }, result = tokio::spawn(telegram) => { - match result { - Err(e) => { - error!("Telegram message receiving task failed: {}", e); - } - Ok(Err(e)) => { - error!("Telegram message receiving task failed: {}", e); - } - Ok(Ok(())) => { - info!("Telegram message receiving task finished"); - } - } + info!("Telegram message receiving task finished"); + result??; }, result = tokio::spawn(bridge(rx)) => { - match result { - Err(e) => { - error!("Bridge task failed: {}", e); - } - Ok(()) => { - info!("Bridge task finished"); - } - } + info!("Bridge task finished"); + result?; }, } diff --git a/src/tasks/factorio.rs b/src/tasks/factorio.rs index c35af3b..fa84626 100644 --- a/src/tasks/factorio.rs +++ b/src/tasks/factorio.rs @@ -8,13 +8,13 @@ use tokio::sync::mpsc; use tracing::{error, info}; pub async fn run(tx: mpsc::Sender) -> Result<()> { - if CONFIG.retry { - loop { - if let Err(e) = create_reader(&tx).await { - error!("Error reading log file: {}", e); - } - } - } + // if CONFIG.retry { + // loop { + // if let Err(e) = create_reader(&tx).await { + // error!("Error reading log file: {}", e); + // } + // } + // } create_reader(&tx).await?;