feat(#1107): hivectl agents restart / restart-all commands
This commit is contained in:
parent
ce52419fe4
commit
26f2c1f59b
3 changed files with 116 additions and 5 deletions
|
|
@ -140,6 +140,32 @@ async fn dispatch(req: &HostRequest, coord: Arc<Coordinator>) -> HostResponse {
|
|||
});
|
||||
HostResponse::success()
|
||||
}
|
||||
HostRequest::Restart { name } => {
|
||||
tracing::info!(%name, "restart");
|
||||
lifecycle::restart(name).await?;
|
||||
HostResponse::success()
|
||||
}
|
||||
HostRequest::RestartAll => {
|
||||
tracing::info!("restart-all");
|
||||
let agents = lifecycle::list().await?;
|
||||
let mut errors: Vec<String> = Vec::new();
|
||||
for agent in &agents {
|
||||
if let Err(e) = lifecycle::restart(agent).await {
|
||||
tracing::warn!(%agent, error = ?e, "restart-all: failed to restart agent");
|
||||
errors.push(format!("{agent}: {e:#}"));
|
||||
}
|
||||
}
|
||||
if errors.is_empty() {
|
||||
HostResponse::list(agents)
|
||||
} else {
|
||||
HostResponse {
|
||||
ok: false,
|
||||
error: Some(errors.join("; ")),
|
||||
agents: Some(agents),
|
||||
approvals: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
HostRequest::Destroy { name, purge } => {
|
||||
actions::destroy(&coord, name, *purge).await?;
|
||||
HostResponse::success()
|
||||
|
|
|
|||
Loading…
Reference in a new issue