pub async fn run_daemon_with_boot_guard<D: DaemonDispatch>(
dispatcher: D,
boot_guard: Option<File>,
) -> Result<()>Expand description
Run the daemon using a startup lock acquired by the caller before
building dispatcher, so a second process racing to boot (e.g. two
kkernel mcp --daemon spawns before either has bound its socket) cannot
run migrations/FTS DDL concurrently against the same database file.
boot_guard is only None on non-unix targets, where there is no
advisory boot lock to hold in the first place; every unix daemon-mode
caller passes Some.
The guard is held across cleanup → bind → pid-write, then dropped. The
caller must not still be holding a different handle to the same lock
file when this function is entered — see the “Deadlock note” on the
_startup_lock binding below for why that would self-deadlock on flock.