Our Personal Data Server from scratch! tranquil.farm
oauth atproto pds rust postgresql objectstorage fun

feat: add version information to _health endpoint

authored by diddyfo.id and committed by tangled.org 1e02c580 e2f26c25

+25 -13
+14 -3
crates/tranquil-pds/src/api/server/meta.rs
··· 1 use crate::state::AppState; 2 use crate::util::{discord_app_id, discord_bot_username, telegram_bot_username}; 3 use axum::{Json, extract::State, http::StatusCode, response::IntoResponse}; ··· 55 "did": format!("did:web:{}", pds_hostname), 56 "links": links, 57 "contact": contact, 58 - "version": env!("CARGO_PKG_VERSION"), 59 "availableCommsChannels": get_available_comms_channels(), 60 "selfHostedDidWebEnabled": is_self_hosted_did_web_enabled() 61 }); ··· 72 } 73 pub async fn health(State(state): State<AppState>) -> impl IntoResponse { 74 match state.infra_repo.health_check().await { 75 - Ok(true) => (StatusCode::OK, "OK"), 76 - _ => (StatusCode::SERVICE_UNAVAILABLE, "Service Unavailable"), 77 } 78 }
··· 1 + use crate::BUILD_VERSION; 2 use crate::state::AppState; 3 use crate::util::{discord_app_id, discord_bot_username, telegram_bot_username}; 4 use axum::{Json, extract::State, http::StatusCode, response::IntoResponse}; ··· 56 "did": format!("did:web:{}", pds_hostname), 57 "links": links, 58 "contact": contact, 59 + "version": BUILD_VERSION, 60 "availableCommsChannels": get_available_comms_channels(), 61 "selfHostedDidWebEnabled": is_self_hosted_did_web_enabled() 62 }); ··· 73 } 74 pub async fn health(State(state): State<AppState>) -> impl IntoResponse { 75 match state.infra_repo.health_check().await { 76 + Ok(true) => ( 77 + StatusCode::OK, 78 + Json(json!({ 79 + "version": format!("tranquil {}", BUILD_VERSION) 80 + })), 81 + ), 82 + _ => ( 83 + StatusCode::SERVICE_UNAVAILABLE, 84 + Json(json!({ 85 + "error": "Service Unavailable" 86 + })), 87 + ), 88 } 89 }
+10
crates/tranquil-pds/src/lib.rs
··· 43 pub use tranquil_db_traits::AccountStatus; 44 pub use types::{AccountState, AtIdentifier, AtUri, Did, Handle, Nsid, Rkey}; 45 46 pub fn app(state: AppState) -> Router { 47 let xrpc_router = Router::new() 48 .route("/_health", get(api::server::health))
··· 43 pub use tranquil_db_traits::AccountStatus; 44 pub use types::{AccountState, AtIdentifier, AtUri, Did, Handle, Nsid, Rkey}; 45 46 + #[cfg(debug_assertions)] 47 + pub const BUILD_VERSION: &str = concat!( 48 + env!("CARGO_PKG_VERSION"), 49 + " (built ", 50 + env!("BUILD_TIMESTAMP"), 51 + ")" 52 + ); 53 + #[cfg(not(debug_assertions))] 54 + pub const BUILD_VERSION: &str = env!("CARGO_PKG_VERSION"); 55 + 56 pub fn app(state: AppState) -> Router { 57 let xrpc_router = Router::new() 58 .route("/_health", get(api::server::health))
+1 -10
crates/tranquil-pds/src/main.rs
··· 5 use std::sync::Arc; 6 use tokio_util::sync::CancellationToken; 7 use tracing::{error, info, warn}; 8 use tranquil_pds::comms::{CommsService, DiscordSender, EmailSender, SignalSender, TelegramSender}; 9 - 10 - #[cfg(debug_assertions)] 11 - const BUILD_VERSION: &str = concat!( 12 - env!("CARGO_PKG_VERSION"), 13 - " (built ", 14 - env!("BUILD_TIMESTAMP"), 15 - ")" 16 - ); 17 - #[cfg(not(debug_assertions))] 18 - const BUILD_VERSION: &str = env!("CARGO_PKG_VERSION"); 19 20 use tranquil_pds::crawlers::{Crawlers, start_crawlers_service}; 21 use tranquil_pds::scheduled::{
··· 5 use std::sync::Arc; 6 use tokio_util::sync::CancellationToken; 7 use tracing::{error, info, warn}; 8 + use tranquil_pds::BUILD_VERSION; 9 use tranquil_pds::comms::{CommsService, DiscordSender, EmailSender, SignalSender, TelegramSender}; 10 11 use tranquil_pds::crawlers::{Crawlers, start_crawlers_service}; 12 use tranquil_pds::scheduled::{