mirror of
https://github.com/atuinsh/atuin.git
synced 2025-07-07 13:15:09 +00:00
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:
parent
1e72e982e0
commit
544f3370da
4 changed files with 35 additions and 1 deletions
15
crates/atuin-server/src/handlers/health.rs
Normal file
15
crates/atuin-server/src/handlers/health.rs
Normal 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" }),
|
||||
)
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue