pub fn kickstart_if_supervised() -> boolExpand description
Start the daemon under launchd supervision, returning true only when
it actually ran the service via launchctl kickstart.
The CLI calls this from spawn_daemon before falling back to a direct
Command spawn. A direct spawn produces an unsupervised daemon:
launchctl print reports state = not running and KeepAlive never
fires, so a kill -9 is never restarted. Kickstarting an already
bootstrapped service is what makes KeepAlive({SuccessfulExit=false})
genuinely protect the steady-state daemon.
Returns false — and the caller spawns directly — unless all hold:
- the plist exists at
~/Library/LaunchAgents/<LABEL>.plist, and - its
ProgramArgumentsbinary equals the current exe (no stale path left behind by a moved/upgraded binary), and - the service is bootstrapped (
launchctl printsucceeds).
Those guards keep the first-ever run (no plist yet) and the
post-upgrade run (plist still names the old binary) on the direct-spawn
path. That spawned daemon’s own ensure_registered then rewrites the
plist to the current exe and re-bootstraps, so the next spawn sees a
fresh, loaded service and converges onto this supervised path.