- 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)
24 lines
853 B
Rust
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);
|
|
}
|