Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/atuin-server/src/handlers/health.rs
Original file line number Diff line number Diff line change
@@ -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" }),
)
}
1 change: 1 addition & 0 deletions crates/atuin-server/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions crates/atuin-server/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ services:
ATUIN_OPEN_REGISTRATION: "true"
ATUIN_DB_URI: postgres://$ATUIN_DB_USERNAME:$ATUIN_DB_PASSWORD@db/$ATUIN_DB_NAME
RUST_LOG: info,atuin_server=debug
healthcheck:
enchantednatures marked this conversation as resolved.
Show resolved Hide resolved
test: ["CMD", "curl", "-f", "http://localhost:8888/healthz"]
interval: 10s
timeout: 5s
retries: 3
postgresql:
image: postgres:14
restart: unless-stopped
Expand Down
19 changes: 18 additions & 1 deletion k8s/atuin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,31 @@ spec:
image: ghcr.io/atuinsh/atuin:latest
name: atuin
ports:
- containerPort: 8888
- containerPort: &port 8888
resources:
limits:
cpu: 250m
memory: 1Gi
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
Expand Down
Loading