feat: extend main-server artifact consumers

This commit is contained in:
Codex
2026-05-20 01:07:52 +00:00
parent b28f693fda
commit 93d9488d36
17 changed files with 519 additions and 34 deletions
@@ -2681,6 +2681,9 @@ fn main() {
if env::args().any(|arg| arg == "--healthcheck") {
std::process::exit(if run_healthcheck(config.port) { 0 } else { 1 });
}
if env::args().any(|arg| arg == "--print-health") {
std::process::exit(if print_health(config.port) { 0 } else { 1 });
}
let state = AppState {
config,
started_at: now_iso(),
@@ -2726,6 +2729,30 @@ fn run_healthcheck(port: u16) -> bool {
stream.read_to_string(&mut body).is_ok() && body.contains("\"ok\": true")
}
fn print_health(port: u16) -> bool {
let Ok(mut stream) = TcpStream::connect(("127.0.0.1", port)) else {
return false;
};
let _ = stream.set_read_timeout(Some(std::time::Duration::from_secs(3)));
let _ = stream.set_write_timeout(Some(std::time::Duration::from_secs(3)));
if stream
.write_all(b"GET /health HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\n\r\n")
.is_err()
{
return false;
}
let mut response = String::new();
if stream.read_to_string(&mut response).is_err() {
return false;
}
if let Some((_, body)) = response.split_once("\r\n\r\n") {
println!("{}", body.trim());
} else {
println!("{}", response.trim());
}
response.contains("\"ok\": true")
}
#[cfg(test)]
mod tests {
use super::*;