Skip to content

The agent that grows with you

merge(launchd): integrate current upstream main into force-retry fix

Brian Fernstrom6554022cdfc8
diff --cc hermes_cli/gateway_launchd.py
index ae928f3eac9,8ffc3d4929f..6bd6b24db8a
--- a/hermes_cli/gateway_launchd.py
+++ b/hermes_cli/gateway_launchd.py
@@@ -605,13 -615,8 +615,13 @@@ def launchd_install(force: bool = False
# Loading the plist starts the gateway (RunAtLoad), so a no-start install writes it without
# loading it. A gateway that launchd already runs is still reloaded; this install did not start it.
load = start_now or _gw()._launchctl_label_supervising_process(label)
+ # A forced reinstall over a live job must remember the incumbent before bootstrap starts.
+ # _launchctl_bootstrap() handles EIO by booting the stale label out and retrying once, but
+ # that immediate retry races the old gateway's drain (#120629). The install path can wait
+ # because it runs outside the supervised gateway process.
+ force_old_pid = _gw()._launchctl_supervised_pid(label) if force and load else None
- if plist_path.exists() and not force:
+ if plist_path.exists() and not (force or force_unit_path):
if _gw().launchd_plist_is_current():
print(f"Service already installed at: {plist_path}")
print("Use --force to reinstall")