Files
momentry_core/build.rs
Accusys 6927415c41 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)
2026-05-14 14:59:30 +08:00

24 lines
853 B
Rust

fn main() {
let version = std::env::var("CARGO_PKG_VERSION").unwrap_or_else(|_| "unknown".to_string());
let git_hash = std::process::Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.and_then(|o| String::from_utf8(o.stdout).ok())
.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);
}