objectstore_server/endpoints/
health.rs1use axum::http::StatusCode;
2use axum::response::IntoResponse;
3use axum::{Router, routing};
4
5use crate::state::ServiceState;
6
7pub const SHUTDOWN_MARKER_PATH: &str = "/tmp/objectstore.down";
8
9pub fn router() -> Router<ServiceState> {
10 Router::new()
11 .route("/health", routing::get(health))
12 .route("/ready", routing::get(ready))
13}
14
15async fn health() -> impl IntoResponse {
16 "OK"
17}
18
19async fn ready() -> impl IntoResponse {
20 if tokio::fs::try_exists(SHUTDOWN_MARKER_PATH)
21 .await
22 .unwrap_or(false)
23 {
24 tracing::debug!("Shutdown marker exists, failing readiness");
25 (StatusCode::SERVICE_UNAVAILABLE, "Shutting down")
26 } else {
27 (StatusCode::OK, "OK")
28 }
29}