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
+25 -1
View File
@@ -1,5 +1,8 @@
use crate::{bot::Bot, gitea::WebhookType, state::AppState};
use dotenvy::dotenv;
use tokio::signal::unix::{SignalKind, signal};
use tokio_util::sync::CancellationToken;
use tracing::{info, warn};
use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt};
@@ -54,11 +57,32 @@ async fn run() -> anyhow::Result<()> {
"Starting Herald"
);
let shutdown = CancellationToken::new();
let bot = Bot::new(config.clone())?;
let (tx, rx) = tokio::sync::mpsc::channel::<WebhookType>(config.bot_max_concurrent * 2);
let app_state = AppState { bot_tx: tx, config };
tokio::try_join!(bot.start(rx), api::start(app_state))?;
let signal = async {
let mut sigterm = signal(SignalKind::terminate())?;
let mut sigint = signal(SignalKind::interrupt())?;
tokio::select! {
_ = sigterm.recv() => info!("Received SIGTERM"),
_ = sigint.recv() => info!("Received SIGINT"),
}
info!("Shutting down...");
shutdown.cancel();
anyhow::Ok(())
};
tokio::try_join!(
bot.start(rx, shutdown.clone()),
api::start(app_state, shutdown.clone()),
signal
)?;
info!("Shutdown complete");
Ok(())
}