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
|
|
@ -47,6 +47,7 @@ fn main() -> Result<()> {
|
|||
}
|
||||
|
||||
async fn serve() -> Result<()> {
|
||||
let stop = swarm_secret_client::shutdown_signal();
|
||||
hive_log::init();
|
||||
swarm_secret_client::install_crypto_provider();
|
||||
let var = |name: &str| {
|
||||
|
|
@ -92,7 +93,8 @@ async fn serve() -> Result<()> {
|
|||
let mut requests = queue
|
||||
.queue_subscribe(SUBJECT, QUEUE_GROUP.to_owned())
|
||||
.await
|
||||
.with_context(|| format!("subscribing to {SUBJECT}"))?;
|
||||
.with_context(|| format!("subscribing to {SUBJECT}"))?
|
||||
.take_until(stop.clone());
|
||||
tracing::info!(subject = SUBJECT, "review classifier: awaiting try-outs");
|
||||
|
||||
let models = std::sync::Arc::new(models);
|
||||
|
|
@ -115,7 +117,10 @@ async fn serve() -> Result<()> {
|
|||
}
|
||||
});
|
||||
}
|
||||
bail!("the subscription to {SUBJECT} ended")
|
||||
if stop.peek().is_none() {
|
||||
bail!("the subscription to {SUBJECT} ended");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Decode one request, answer it and log the run.
|
||||
|
|
|
|||
Loading…
Reference in a new issue