Watch
0
0
Fork
You've already forked hyperhive
0

queue consumers: stop taking messages on sigterm and exit 0

This commit is contained in:
atlas 2026-11-18 03:28:12 +01:00 • committed by mara
commit a8775f1a7a

View file

@ -88,6 +88,7 @@ fn push_budget(reply_by: tokio::time::Instant) -> Duration {
#[tokio::main]
async fn main() -> Result<()> {
let stop = swarm_secret_client::shutdown_signal();
hive_log::init();
swarm_secret_client::install_crypto_provider();
let var = |name: &str| {
@ -174,8 +175,19 @@ async fn main() -> Result<()> {
let slot = Arc::new(tokio::sync::Semaphore::new(1));
serve_meta_builds(&queue, &publisher, Store, &builder, &slot, &metrics).await?;
answer_builds(requests, publisher, Store, builder, slot, metrics).await;
bail!("the subscription to {SUBJECT} ended")
answer_builds(
requests.take_until(stop.clone()),
publisher,
Store,
builder,
slot,
metrics,
)
.await;
if stop.peek().is_none() {
bail!("the subscription to {SUBJECT} ended");
}
Ok(())
}
/// Where a reply goes. [`Queue`] in production; tests record.
@ -260,6 +272,8 @@ async fn send_reply(
}
/// Answer every PR check, each in its own task, with the build's result.
/// Returns once `requests` ends; a build still running is not waited for, and
/// its requester gets no reply, as when the process is killed.
async fn answer_builds(
mut requests: impl Stream<Item = Message> + Unpin,
publisher: impl Publisher,