manager events: Spawned/Rebuilt/Killed/Destroyed + start button

This commit is contained in:
müde 2026-05-15 17:38:41 +02:00
parent 06ea0cf283
commit 37c6504462
9 changed files with 165 additions and 70 deletions

View file

@ -47,6 +47,7 @@ pub async fn serve(port: u16, coord: Arc<Coordinator>) -> Result<()> {
.route("/destroy/{name}", post(post_destroy))
.route("/kill/{name}", post(post_kill))
.route("/restart/{name}", post(post_restart))
.route("/start/{name}", post(post_start))
.route("/rebuild/{name}", post(post_rebuild))
.route("/update-all", post(post_update_all))
.route("/request-spawn", post(post_request_spawn))
@ -313,6 +314,11 @@ async fn post_kill(State(state): State<AppState>, AxumPath(name): AxumPath<Strin
match lifecycle::kill(&logical).await {
Ok(()) => {
state.coord.unregister_agent(&logical);
state
.coord
.notify_manager(&hive_sh4re::HelperEvent::Killed {
agent: logical.clone(),
});
Redirect::to("/").into_response()
}
Err(e) => error_response(&format!("kill {logical} failed: {e:#}")),
@ -327,6 +333,14 @@ async fn post_restart(State(_state): State<AppState>, AxumPath(name): AxumPath<S
}
}
async fn post_start(State(_state): State<AppState>, AxumPath(name): AxumPath<String>) -> Response {
let logical = strip_container_prefix(&name);
match lifecycle::start(&logical).await {
Ok(()) => Redirect::to("/").into_response(),
Err(e) => error_response(&format!("start {logical} failed: {e:#}")),
}
}
async fn post_update_all(State(state): State<AppState>) -> Response {
let Some(current_rev) = crate::auto_update::current_flake_rev(&state.coord.hyperhive_flake)
else {