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:
9
build.rs
9
build.rs
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user