feat: health/detailed — add pipeline status section (scripts, models, ffmpeg, embed, gdino, llm)

This commit is contained in:
Accusys
2026-05-14 17:01:54 +08:00
parent c589eb10cf
commit 513b9e72fc

View File

@@ -377,6 +377,20 @@ struct DetailedHealthResponse {
uptime_ms: u64,
services: ServiceHealth,
resources: ResourceStatus,
pipeline: PipelineStatus,
}
#[derive(Debug, Serialize)]
struct PipelineStatus {
scripts: bool,
models: bool,
ffmpeg: bool,
/// Embedding server (port 11436)
embedding_server: ServiceStatus,
/// GDINO API (port 8080)
gdino_api: ServiceStatus,
/// LLM via llama.cpp (port 8082)
llm: ServiceStatus,
}
#[derive(Debug, Serialize)]
@@ -450,6 +464,13 @@ async fn health_detailed(State(state): State<AppState>) -> Json<DetailedHealthRe
let sys = SystemResources::check();
let scripts_dir = std::path::Path::new("/Users/accusys/momentry_core_0.1/scripts");
let models_dir = std::path::Path::new("/Users/accusys/momentry_core_0.1/models");
let ffmpeg_full = std::path::Path::new("/opt/homebrew/opt/ffmpeg-full/bin/ffmpeg");
let has_scripts = scripts_dir.is_dir();
let has_models = models_dir.is_dir();
let has_ffmpeg = ffmpeg_full.exists();
Json(DetailedHealthResponse {
status: overall_status.to_string(),
version: env!("BUILD_VERSION").to_string(),
@@ -472,6 +493,14 @@ async fn health_detailed(State(state): State<AppState>) -> Json<DetailedHealthRe
gpu_utilization: sys.gpu_utilization,
gpu_memory_used_pct: sys.gpu_memory_used_pct,
},
pipeline: PipelineStatus {
scripts: has_scripts,
models: has_models,
ffmpeg: has_ffmpeg,
embedding_server: check_http("http://127.0.0.1:11436/health").await,
gdino_api: check_http("http://127.0.0.1:8080/health").await,
llm: check_http("http://127.0.0.1:8082/health").await,
},
})
}
@@ -605,6 +634,32 @@ async fn check_mongodb(cache: &MongoCache) -> ServiceStatus {
}
}
async fn check_http(url: &str) -> ServiceStatus {
let start = Instant::now();
match reqwest::get(url).await {
Ok(resp) => {
if resp.status().is_success() {
ServiceStatus {
status: "ok".to_string(),
latency_ms: Some(start.elapsed().as_millis() as u64),
error: None,
}
} else {
ServiceStatus {
status: "error".to_string(),
latency_ms: Some(start.elapsed().as_millis() as u64),
error: Some(format!("HTTP {}", resp.status())),
}
}
}
Err(e) => ServiceStatus {
status: "error".to_string(),
latency_ms: Some(start.elapsed().as_millis() as u64),
error: Some(e.to_string()),
},
}
}
fn generate_query_hash(query: &str, uuid: Option<&str>, limit: usize) -> String {
let data = serde_json::json!({
"query": query,