feat(health): add health check endpoint at /healthz (#2549)

* feat(health): add health check endpoint at `/healthz`

* feat(health-check): remove invalid health-check from docker compose
This commit is contained in:
Hunter Casten 2025-03-09 15:43:27 -06:00 committed by GitHub
parent 1e72e982e0
commit 544f3370da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 1 deletions

View file

@ -0,0 +1,15 @@
use axum::{http, response::IntoResponse, Json};
use serde::Serialize;
#[derive(Serialize)]
pub struct HealthResponse {
pub status: &'static str,
}
pub async fn health_check() -> impl IntoResponse {
(
http::StatusCode::OK,
Json(HealthResponse { status: "healthy" }),
)
}

View file

@ -4,6 +4,7 @@ use axum::{extract::State, http, response::IntoResponse, Json};
use crate::router::AppState;
pub mod health;
pub mod history;
pub mod record;
pub mod status;

View file

@ -111,6 +111,7 @@ pub struct AppState<DB: Database> {
pub fn router<DB: Database>(database: DB, settings: Settings<DB::Settings>) -> Router {
let routes = Router::new()
.route("/", get(handlers::index))
.route("/healthz", get(handlers::health::health_check))
.route("/sync/count", get(handlers::history::count))
.route("/sync/history", get(handlers::history::list))
.route("/sync/calendar/:focus", get(handlers::history::calendar))

View file

@ -33,7 +33,7 @@ spec:
image: ghcr.io/atuinsh/atuin:latest
name: atuin
ports:
- containerPort: 8888
- containerPort: &port 8888
resources:
limits:
cpu: 250m
@ -41,6 +41,23 @@ spec:
requests:
cpu: 250m
memory: 1Gi
startupProbe:
httpGet:
path: /healthz
port: *port
failureThreshold: 30
periodSeconds: 10
livenessProbe:
httpGet:
path: /healthz
port: *port
initialDelaySeconds: 3
periodSeconds: 3
readinessProbe:
tcpSocket:
port: *port
initialDelaySeconds: 15
periodSeconds: 10
volumeMounts:
- mountPath: /config
name: atuin-claim0