Watch
0
0
Fork
You've already forked hyperhive
0

swarm daemons: opt-in /healthz and /readyz listener, and /readyz on the controller

This commit is contained in:
atlas 2026-11-18 13:52:36 +01:00 • committed by mara
commit c21b158884

View file

@ -178,6 +178,11 @@ struct Args {
/// without.
#[arg(long, default_value = "swarm-nats-auth")]
store_cert_role: String,
/// Address to serve `/healthz` and `/readyz` on. Nothing listens unless set;
/// the environment variable `SWARM_NATS_AUTH_HEALTH_ADDR` is read when the
/// flag is absent.
#[arg(long)]
health_addr: Option<std::net::SocketAddr>,
}
#[tokio::main]
@ -240,6 +245,14 @@ async fn serve(args: Args, stop: swarm_secret_client::Shutdown) -> anyhow::Resul
.with_claude_logins(args.claude_login_clients.clone())
.with_notify_routers(args.notify_router_clients.clone())
.with_stts(args.stt_clients.clone());
let health = swarm_secret_client::health::Health::start(
swarm_secret_client::health::STALE_AFTER,
args.health_addr,
"SWARM_NATS_AUTH_HEALTH_ADDR",
stop.clone(),
)
.await
.context("starting the health listener")?;
let http = reqwest::Client::new();
let settings = swarm_secret_client::client::Settings::from_env()
.context("reading the secret store's address and this responder's identity")?;
@ -261,6 +274,7 @@ async fn serve(args: Args, stop: swarm_secret_client::Shutdown) -> anyhow::Resul
.connect(&args.nats_url)
.await
.with_context(|| format!("connect to {}", args.nats_url))?;
swarm_queue_client::ready_when_connected(&health, &client);
let requests = client
.subscribe(AUTH_SUBJECT)
.await
@ -281,7 +295,7 @@ async fn serve(args: Args, stop: swarm_secret_client::Shutdown) -> anyhow::Resul
issuer,
});
answer_each(
requests.take_until(stop.clone()),
health.beating(requests.take_until(stop.clone())),
CONCURRENT_REQUESTS,
move |msg| {
let responder = Arc::clone(&responder);