fix(#1164,#1171): harness writes status file, c0re just rescans
This commit is contained in:
parent
a9ce8a945f
commit
049ae47191
5 changed files with 75 additions and 26 deletions
|
|
@ -239,29 +239,13 @@ pub(crate) async fn dispatch_shared(
|
|||
if let Err(message) = crate::limits::check_status_text(text) {
|
||||
return Some(hive_sh4re::Response::Err { message });
|
||||
}
|
||||
let path =
|
||||
crate::coordinator::Coordinator::agent_notes_dir(agent).join("hyperhive-status");
|
||||
let result = if text.trim().is_empty() {
|
||||
std::fs::remove_file(&path).or_else(|e| {
|
||||
if e.kind() == std::io::ErrorKind::NotFound {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(e)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
std::fs::write(&path, format!("{}\n", text.trim()))
|
||||
};
|
||||
match result {
|
||||
Ok(()) => {
|
||||
let coord2 = Arc::clone(coord);
|
||||
tokio::spawn(async move { coord2.rescan_containers_and_emit().await });
|
||||
hive_sh4re::Response::Ok
|
||||
}
|
||||
Err(e) => hive_sh4re::Response::Err {
|
||||
message: format!("set_status write failed: {e}"),
|
||||
},
|
||||
}
|
||||
// The harness writes the status file to its own `state/` dir
|
||||
// before sending this request (it runs as the agent user, so
|
||||
// it has write access). We just trigger a dashboard rescan so
|
||||
// the new value is reflected immediately.
|
||||
let coord2 = Arc::clone(coord);
|
||||
tokio::spawn(async move { coord2.rescan_containers_and_emit().await });
|
||||
hive_sh4re::Response::Ok
|
||||
}
|
||||
hive_sh4re::Request::GetAgentMeta { name } => {
|
||||
let target = name.as_deref().unwrap_or(agent);
|
||||
|
|
|
|||
Loading…
Reference in a new issue