queue consumers: stop taking messages on sigterm and exit 0
This commit is contained in:
parent
a089da25a5
commit
a8775f1a7a
1 changed files with 164 additions and 53 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue