Files
yetone 58ea9cade8 daemon: a launch agent written as Background is mended to Standard (#2961)
The commit before writes ProcessType Standard for new installs. Every
agent already installed kept Background until the user ran `magpie
daemon install` again, which no one is told to do. Now `magpie serve`
rewrites that one line of the installed launch agent as it starts
(daemon.Mend), leaving the rest of the user's install as it is, and
says so in the log. launchd reads the file when it loads the agent, not on
a kickstart: so it is taken up at the next login, or at `magpie daemon
restart`, which now takes the agent out and loads it again instead of
`kickstart -k` (and `start` does the same when it mends the file).

This is the same class as #6261: the gateway's process held to
background priority by macOS while agents wait on it.

Run:
- TestLaunchdOldAgentMended: an installed agent rewritten to the old
  Background line is mended byte for byte to what Install writes, 0600,
  with no launchctl call from Mend; Restart boots it out before loading
  it; on Linux nothing is touched. TestLaunchdInstall's restart now
  expects bootout, then load. Broken by hand (mended never mends):
  red at "Mend: the plist is" and "want a bootout first".
- TestLaunchdInstall (plutil -lint on darwin), the whole daemon package,
  vet on darwin, linux, windows: ok; and the package run named in 6261's commit: all ok (gateway 908s, plugin 159s, cli 52s) at base 7eecbcc56; at the pushed head (rebased on 459d668b3, which touches none of these files) build, gofmt, linux and windows vet, and awake, daemon, cli tests ok again

- Real launchd on mote (macOS 27.2), a throwaway agent of its own label
  running /bin/sleep: as Background, launchctl print says "spawn type =
  background (5)" and ps pri 4, the band #6261's app was napped into.
  The file rewritten to Standard and `kickstart -k`: still background
  (5), pri 4. bootout + bootstrap: "spawn type = daemon (3)", pri 20.
  So a kickstart doesn't take the mended file up, and restart's reload
  does.

Not tried: a real `magpie daemon install` on mote (it would take the
gateway's port from the other sessions there).
2026-11-13 21:31:01 +08:00
..