feat: add version information to _health endpoint

This commit is contained in:
penny
2026-03-01 15:22:59 -05:00
committed by Tangled
parent e2f26c259f
commit 1e02c5803f
3 changed files with 25 additions and 13 deletions

View File

@@ -1,3 +1,4 @@
use crate::BUILD_VERSION;
use crate::state::AppState;
use crate::util::{discord_app_id, discord_bot_username, telegram_bot_username};
use axum::{Json, extract::State, http::StatusCode, response::IntoResponse};
@@ -55,7 +56,7 @@ pub async fn describe_server() -> impl IntoResponse {
"did": format!("did:web:{}", pds_hostname),
"links": links,
"contact": contact,
"version": env!("CARGO_PKG_VERSION"),
"version": BUILD_VERSION,
"availableCommsChannels": get_available_comms_channels(),
"selfHostedDidWebEnabled": is_self_hosted_did_web_enabled()
});
@@ -72,7 +73,17 @@ pub async fn describe_server() -> impl IntoResponse {
}
pub async fn health(State(state): State<AppState>) -> impl IntoResponse {
match state.infra_repo.health_check().await {
Ok(true) => (StatusCode::OK, "OK"),
_ => (StatusCode::SERVICE_UNAVAILABLE, "Service Unavailable"),
Ok(true) => (
StatusCode::OK,
Json(json!({
"version": format!("tranquil {}", BUILD_VERSION)
})),
),
_ => (
StatusCode::SERVICE_UNAVAILABLE,
Json(json!({
"error": "Service Unavailable"
})),
),
}
}

View File

@@ -43,6 +43,16 @@ use tower_http::cors::{Any, CorsLayer};
pub use tranquil_db_traits::AccountStatus;
pub use types::{AccountState, AtIdentifier, AtUri, Did, Handle, Nsid, Rkey};
#[cfg(debug_assertions)]
pub const BUILD_VERSION: &str = concat!(
env!("CARGO_PKG_VERSION"),
" (built ",
env!("BUILD_TIMESTAMP"),
")"
);
#[cfg(not(debug_assertions))]
pub const BUILD_VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn app(state: AppState) -> Router {
let xrpc_router = Router::new()
.route("/_health", get(api::server::health))

View File

@@ -5,18 +5,9 @@ use std::process::ExitCode;
use std::sync::Arc;
use tokio_util::sync::CancellationToken;
use tracing::{error, info, warn};
use tranquil_pds::BUILD_VERSION;
use tranquil_pds::comms::{CommsService, DiscordSender, EmailSender, SignalSender, TelegramSender};
#[cfg(debug_assertions)]
const BUILD_VERSION: &str = concat!(
env!("CARGO_PKG_VERSION"),
" (built ",
env!("BUILD_TIMESTAMP"),
")"
);
#[cfg(not(debug_assertions))]
const BUILD_VERSION: &str = env!("CARGO_PKG_VERSION");
use tranquil_pds::crawlers::{Crawlers, start_crawlers_service};
use tranquil_pds::scheduled::{
backfill_genesis_commit_blocks, backfill_record_blobs, backfill_repo_rev, backfill_user_blocks,