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
|
|
@ -115,6 +115,7 @@ async fn connect_queue(var: Var<'_>) -> Result<async_nats::Client> {
|
|||
|
||||
#[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| {
|
||||
|
|
@ -151,7 +152,8 @@ async fn main() -> Result<()> {
|
|||
let mut requests = queue
|
||||
.queue_subscribe(subject_wildcard(), QUEUE_GROUP.to_owned())
|
||||
.await
|
||||
.context("subscribing to the request subject")?;
|
||||
.context("subscribing to the request subject")?
|
||||
.take_until(stop.clone());
|
||||
tracing::info!(
|
||||
subject = subject_wildcard(),
|
||||
"swarm-stt: answering requests"
|
||||
|
|
@ -207,7 +209,10 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
});
|
||||
}
|
||||
bail!("the request subscription ended")
|
||||
if stop.peek().is_none() {
|
||||
bail!("the request subscription ended");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// One agent's place among the requests in flight; dropping it frees the place.
|
||||
|
|
|
|||
Loading…
Reference in a new issue