pub async fn start_admin_server(
admin_config: &AdminConfig,
state: Arc<SharedState>,
shutdown_rx: Receiver<bool>,
drain_timeout: Duration,
) -> Result<(), Box<dyn Error>>Expand description
Binds the admin listener on admin_config.bind:port and serves the admin
API and UI until the server exits.
The API routes (/api/*, /healthz, /readyz, /metrics) are wrapped in
the Basic Auth middleware using credentials from AdminConfig; any path
not matched by the API falls back to the embedded SPA — when the binary is
compiled with the ui feature and admin.ui_enabled is true (the
default) — served without auth (the SPA’s own API calls carry
credentials).
When admin_config.tls is set, the admin listener is TLS-terminated using
the same acceptor helper as the data plane; otherwise it serves plain HTTP.
On shutdown (shutdown_rx flips to true) the accept loop stops and
in-flight requests are drained (up to drain_timeout), then this returns.
Returns an error for a fail-fast startup problem (bind failure, or an unreadable cert/key when TLS is configured). Per-connection errors — including TLS handshake failures — are logged and do not stop the server.