feat(admin): power controls — stop everything & power off, restart everything
Settings gains a second service button next to restart: stop every managed local model server and exit the gateway process (nothing is respawned; in Docker the restart policy decides). The SPA replaces itself with a static "gateway is off" screen since the API is gone. The restart button is relabeled "Restart everything" to say what it always did — the gateway re-execs itself and managed servers come back with it. Translated in all seven languages.
This commit is contained in:
@@ -184,6 +184,7 @@ pub fn api_routes(admin_token: String) -> Router<SharedState> {
|
||||
.route("/admin/api/logs", get(get_logs).delete(clear_logs))
|
||||
.route("/admin/api/system", get(get_system))
|
||||
.route("/admin/api/restart", post(restart_gateway))
|
||||
.route("/admin/api/shutdown", post(shutdown_gateway))
|
||||
.route("/admin/api/bench", get(bench_list).post(bench_start))
|
||||
.route("/admin/api/config/export", get(config_export))
|
||||
.route("/admin/api/config/import", post(config_import))
|
||||
@@ -2272,6 +2273,20 @@ async fn get_system(State(state): State<SharedState>) -> ApiResult {
|
||||
ok(serde_json::to_value(snap).unwrap_or_else(|_| json!({})))
|
||||
}
|
||||
|
||||
/// Stop every managed local model server and power the gateway off. The 200
|
||||
/// goes out first so the SPA can show its "gateway is off" screen; nothing is
|
||||
/// respawned — the operator starts the gateway again by hand (or the Docker
|
||||
/// restart policy does, in which case this behaves like a restart).
|
||||
async fn shutdown_gateway(State(state): State<SharedState>) -> ApiResult {
|
||||
state.cmf.stop().await;
|
||||
tokio::spawn(async move {
|
||||
tokio::time::sleep(std::time::Duration::from_millis(300)).await;
|
||||
tracing::info!("shutdown requested from the admin console");
|
||||
std::process::exit(0);
|
||||
});
|
||||
ok(json!({ "ok": true }))
|
||||
}
|
||||
|
||||
/// Restart the gateway in place: stop managed model servers, spawn a fresh
|
||||
/// copy of ourselves (it retries the bind while our port frees), then exit.
|
||||
/// In Docker we only exit — we are PID 1, a spawned child would die with the
|
||||
|
||||
Reference in New Issue
Block a user