diff --git a/src/main.rs b/src/main.rs index 9857bcc..52c1880 100644 --- a/src/main.rs +++ b/src/main.rs @@ -351,11 +351,18 @@ async fn main() -> Result<(), MainError> { move || { loop { + tracing::debug!("waiting to send check-in"); + if watchdog_tx.try_send(()).is_err() { tracing::error!("tokio runtime deadlocked"); - vcs_watcher.borrow().par_iter().for_each(|(&guild_id, vcs_in_guild)| { - if let Some(&voice_channel_id) = vcs_in_guild.get_left_for(&discord_user_id) { + vcs_watcher + .borrow() + .par_iter() + .for_each(|(&guild_id, vcs_in_guild)| { + if let Some(&voice_channel_id) = + vcs_in_guild.get_left_for(&discord_user_id) + { let text_channel_id = discord_voice_channel_corresponding_text_channel .get(&guild_id) @@ -364,7 +371,8 @@ async fn main() -> Result<(), MainError> { }) .unwrap_or(voice_channel_id); - let _ = futures::executor::block_on(discord_client.create_message(text_channel_id).content("so sorry I died, I'm in purgatory now, I don't like it here.\nbut I will be back in 5-20 minutes (even if it says I'm still there, I'm not currently recording and will be disconnected soon before later reconnecting and announcing recording again)").into_future()); + tokio::runtime::Runtime::new().unwrap().block_on(discord_client.create_message(text_channel_id).content("so sorry I died, I'm in purgatory now, I don't like it here.\nbut I will be back in 5-20 minutes (even if it says I'm still there, I'm not currently recording and will be disconnected soon before later reconnecting and announcing recording again)").into_future()); + } }); @@ -378,6 +386,8 @@ async fn main() -> Result<(), MainError> { tokio::spawn(async move { loop { + tracing::debug!("waiting to acknowledge the watchdog"); + if watchdog_rx.recv().await.is_err() { tracing::error!("watchdog died (this should be impossible)"); std::process::exit(1);