fix(setup): use LaunchDaemon on macOS so agent starts at boot without login#923
Open
corfehill-cmd wants to merge 1 commit into
Open
fix(setup): use LaunchDaemon on macOS so agent starts at boot without login#923corfehill-cmd wants to merge 1 commit into
corfehill-cmd wants to merge 1 commit into
Conversation
…t login LaunchAgents (~/Library/LaunchAgents/) only run after a user logs in at the console. For a home server or always-on deployment, this means the agent stays dead after a reboot until someone physically logs in. Switch to a LaunchDaemon (/Library/LaunchDaemons/) with the UserName key set to the installing user. LaunchDaemons are loaded by launchd at system boot, before any GUI login, so the agent comes up automatically. Changes: - Rename installMacOSLaunchAgent → installMacOSLaunchDaemon - Write plist to /Library/LaunchDaemons/ (via sudo cp + chown/chmod) - Add UserName and GroupName keys so the process runs as the user - Add HOME env var (LaunchDaemons don't inherit user environment) - Use `sudo launchctl bootstrap system` to load at system scope - Update uninstallAutoStart to boot-out/remove the daemon (+ cleanup any legacy LaunchAgent plist for existing installs) - Migration path: if a legacy ~/Library/LaunchAgents plist exists it is unloaded and removed during install to avoid double-start on login
|
@adrianco is attempting to deploy a commit to the sagemind Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS, instar installs a
LaunchAgentplist into~/Library/LaunchAgents/. LaunchAgents are only loaded after a user logs in at the GUI — so on a home server or always-on Mac, the agent stays dead after a system reboot until someone physically logs in at the console.Solution
Switch to a LaunchDaemon (
/Library/LaunchDaemons/) with theUserNamekey set to the installing user. LaunchDaemons are loaded by launchd at system boot, before any GUI session, so the agent starts automatically after a reboot.Changes
installMacOSLaunchAgent→installMacOSLaunchDaemon/Library/LaunchDaemons/viasudo cp+chown root:wheel+chmod 644UserNameandGroupNamekeys so the process runs as the correct userHOMEenv var (LaunchDaemons do not inherit the user environment)sudo launchctl bootstrap systemto load at system scopeuninstallAutoStarttobootout/remove the daemon plist (with sudo)~/Library/LaunchAgents/plist exists it is automatically unloaded and removed during install so the agent doesn't start twice on loginNotes
The setup wizard runs interactively so the
sudoprompt is visible to the user. ThelaunchctlLoadAllowed()gate (used for test hygiene) is preserved.The fleet watchdog (
installFleetWatchdog) is left as a LaunchAgent for now since it is a periodic check script withStartInterval, not the main boot concern — that can be a follow-up.