feat: add graceful shutdown endpoint for UVM API server and update documentation

This commit is contained in:
2026-09-23 06:30:58 +05:30
parent 0f72ac693a
commit eb6119c797
7 changed files with 119 additions and 9 deletions
+7
View File
@@ -808,6 +808,7 @@ or secret manager when that matters.
| `GET` | `/` | `server.py` | Redirect to `/dashboard` |
| `GET` | `/dashboard` | `dashboard.py` | Public static dashboard shell |
| `GET` | `/health` | `health.py` | Unauthenticated liveness response |
| `POST` | `/exit` | `exit.py` | Request graceful Uvicorn shutdown |
| `GET` | `/diagnostics` | `diagnostics.py` | Host readiness checks |
| `POST` | `/install` | `installation.py` | `{ "force": false }` body |
| `GET` | `/vms` | `vms.py` | List persisted VM records and observed status |
@@ -829,6 +830,12 @@ All management routes use `get_authorized_application()` and require:
X-UVM-Token: <UVM_API_TOKEN>
```
`POST /exit` is a management route. `run_server()` creates the Uvicorn server,
stores it on the FastAPI application state, and runs it in-process. The route
returns `202` before a background task sets `should_exit`, allowing Uvicorn to
deliver the response and perform its normal graceful shutdown. It does not
stop or delete any managed VM.
Request schemas reject unexpected fields. `UvmError` instances are rendered as
JSON errors by `server.py`; Pydantic request validation uses FastAPI's normal
422 response format. Create accepts `name: str | null`, `ports: list | null`,