swarm daemons: opt-in /healthz and /readyz listener, and /readyz on the controller
This commit is contained in:
parent
377bc1d5df
commit
c21b158884
1 changed files with 787 additions and 26 deletions
|
|
@ -55,6 +55,10 @@ struct Args {
|
|||
/// Unix socket to serve on.
|
||||
#[arg(long)]
|
||||
socket: PathBuf,
|
||||
/// Address to serve `/healthz` and `/readyz` on. Nothing listens unless set;
|
||||
/// the environment variable `SWARM_LOGS_AUTH_HEALTH_ADDR` is read when the flag is absent.
|
||||
#[arg(long)]
|
||||
health_addr: Option<std::net::SocketAddr>,
|
||||
/// Cert-auth role this responder logs in to the store as.
|
||||
#[arg(long, default_value = "swarm-logs-auth")]
|
||||
store_cert_role: String,
|
||||
|
|
@ -206,6 +210,15 @@ async fn main() -> anyhow::Result<()> {
|
|||
.with_ansi(false)
|
||||
.init();
|
||||
let args = Args::parse();
|
||||
let health = swarm_secret_client::health::Health::start(
|
||||
swarm_secret_client::health::STALE_AFTER,
|
||||
args.health_addr,
|
||||
"SWARM_LOGS_AUTH_HEALTH_ADDR",
|
||||
stop.clone(),
|
||||
)
|
||||
.await
|
||||
.context("starting the health listener")?;
|
||||
health.beat_on_runtime();
|
||||
|
||||
let settings = swarm_secret_client::client::Settings::from_env()
|
||||
.context("reading the secret store's address and this responder's identity")?;
|
||||
|
|
@ -234,6 +247,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
std::fs::set_permissions(&args.socket, std::fs::Permissions::from_mode(0o666))
|
||||
.with_context(|| format!("chmod {}", args.socket.display()))?;
|
||||
tracing::info!(socket = %args.socket.display(), "swarm-logs-auth listening");
|
||||
health.ready_when(|| true);
|
||||
|
||||
let app = axum::Router::new().fallback(handle).with_state(responder);
|
||||
serve(listener, app, stop).await
|
||||
|
|
|
|||
Loading…
Reference in a new issue