prepare first release with graceful shutdown + containerfile + push to

hub script
This commit is contained in:
2026-06-10 19:23:17 +00:00
parent 9175f9b3a2
commit a30d7c5d90
8 changed files with 86 additions and 8 deletions
+13 -2
View File
@@ -5,6 +5,7 @@ use crate::{
};
use serde::Deserialize;
use std::{sync::Arc, time::Duration};
use tokio_util::sync::CancellationToken;
use tracing::{error, info, instrument};
#[derive(Deserialize, Debug)]
@@ -54,13 +55,23 @@ impl Bot {
pub async fn start(
&self,
mut rx: tokio::sync::mpsc::Receiver<WebhookType>,
shutdown: CancellationToken,
) -> anyhow::Result<()> {
info!("Bot started");
let sem = Arc::new(tokio::sync::Semaphore::new(self.max_concurrent));
let mut tasks = tokio::task::JoinSet::new();
while let Some(wb) = rx.recv().await {
loop {
let wb = tokio::select! {
biased;
_ = shutdown.cancelled() => break,
msg = rx.recv() => match msg {
Some(wb) => wb,
None => break,
},
};
// Drain completed tasks to avoid the JoinSet growing unbounded
while let Some(res) = tasks.try_join_next() {
if let Err(e) = res {
@@ -82,7 +93,7 @@ impl Bot {
// properly before returning
tasks.join_all().await;
info!("Bot shutting down, channel closed");
info!("Bot shutting down complete");
Ok(())
}