Expose scheduled release cycle status and logs
This commit is contained in:
parent
3756d3ffeb
commit
e6fa1337b6
1 changed files with 16 additions and 1 deletions
|
|
@ -73,9 +73,24 @@ pub fn dispatch(args: &[String]) -> Result<(), String> {
|
|||
}
|
||||
}
|
||||
requests.sort_by(|a,b| a["id"].as_str().cmp(&b["id"].as_str()));
|
||||
println!("{}", serde_json::to_string_pretty(&json!({"unit_status":status,"requests":requests})).unwrap());
|
||||
let cycle = match config["cycle_status"].as_str() {
|
||||
Some(path) if Path::new(path).exists() => serde_json::from_slice::<Value>(
|
||||
&fs::read(path).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?,
|
||||
_ => Value::Null,
|
||||
};
|
||||
let schedule = match config["cycle_timer"].as_str() {
|
||||
Some(unit) => output(&["systemctl", "show", unit, "-p", "ActiveState", "-p", "NextElapseUSecRealtime"] )?,
|
||||
None => String::new(),
|
||||
};
|
||||
println!("{}", serde_json::to_string_pretty(&json!({"unit_status":status,"requests":requests,
|
||||
"cycle":cycle,"schedule":schedule})).unwrap());
|
||||
Ok(())
|
||||
}
|
||||
["pipeline", "logs", "latest"] => {
|
||||
let status = Command::new("journalctl").args(["--no-pager", "-n", "200", "-u",
|
||||
text(&config, "cycle_unit")?]).status().map_err(|e| e.to_string())?;
|
||||
if status.success() { Ok(()) } else { Err("cycle log unavailable".into()) }
|
||||
}
|
||||
["pipeline", "logs", id] if id.bytes().all(|c| c.is_ascii_digit()) && !id.is_empty() => {
|
||||
let p = Path::new(text(&config, "control_root")?).join(format!("{id}.log"));
|
||||
let status = Command::new("tail").args(["-n", "200"]).arg(p).status().map_err(|e| e.to_string())?;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue