pub fn spawn(
state: RunStateHandle,
runtime: Option<Handle>,
) -> Result<(PathBuf, JoinHandle<()>)>Expand description
Spawn the inspector server thread. Returns the socket path
it bound to (so the runner can log it) and a JoinHandle
that the caller may keep or drop. The thread closes
gracefully when its RunStateHandle clone is the only
remaining sender — i.e. when the run has fully torn down.
runtime is an optional tokio::runtime::Handle captured
at spawn time. When present, async control writes (set <name> <value>) run via runtime.block_on(...) on the
per-connection thread; the inspector itself stays sync.
When None (e.g. test harnesses without a tokio runtime),
the set command rejects with ERR no_runtime and reads
keep working.
On bind failure the function returns Err and the run
continues without an inspector (this is a diagnostic
affordance, not a critical path).