feat: health API — add build_timestamp + detailed resource status list

- build.rs: BUILD_TIMESTAMP from build time via `date -u`
- GET /health: now returns build_timestamp
- GET /health/detailed: returns build_timestamp + resources block
  (cpu_used/cpu_idle/memory/gpu usage)
This commit is contained in:
Accusys
2026-05-14 14:59:30 +08:00
parent 2c4e32f14a
commit 6927415c41
2 changed files with 39 additions and 0 deletions

View File

@@ -9,6 +9,15 @@ fn main() {
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
let timestamp = std::process::Command::new("date")
.args(["-u", "+%Y-%m-%dT%H:%M:%SZ"])
.output()
.ok()
.and_then(|o| String::from_utf8(o.stdout).ok())
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
println!("cargo:rustc-env=BUILD_VERSION={}", version);
println!("cargo:rustc-env=BUILD_GIT_HASH={}", git_hash);
println!("cargo:rustc-env=BUILD_TIMESTAMP={}", timestamp);
}