-
Notifications
You must be signed in to change notification settings - Fork 206
Description
Summary
Would love to see official guidance or built-in support for running the Happy daemon as a system service (launchd on macOS, systemd on Linux) for auto-start on boot and crash recovery.
Current Approach
I set up a launchd service manually. Here's what worked for me on macOS:
LaunchAgent plist
~/Library/LaunchAgents/com.happy-coder.daemon.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.happy-coder.daemon</string>
<key>ProgramArguments</key>
<array>
<string>/Users/USERNAME/.npm-global/bin/happy</string>
<string>daemon</string>
<string>start-sync</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/Users/USERNAME/.npm-global/bin</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/happy-coder.log</string>
<key>StandardErrorPath</key>
<string>/tmp/happy-coder.err</string>
</dict>
</plist>Setup commands
# Load the service
launchctl load ~/Library/LaunchAgents/com.happy-coder.daemon.plist
# Check status
launchctl list | grep happyBenefits
- Auto-starts on login
- Auto-restarts if daemon crashes
- No need to remember
happy daemon startafter reboot
Potential Issues / Questions
-
Conflict with
happy daemon start: If someone runshappy daemon startmanually while launchd is managing it, could get duplicate processes. Maybe needs mutex/lockfile? -
Path differences: npm global bin location varies (
~/.npm-global/bin,/usr/local/bin, etc.) - would need templating or detection -
start-syncvsstart: I usedstart-syncsince launchd manages the lifecycle. Is this the right subcommand for service mode? -
Updates: After
npm update -g happy-coder, does the daemon need restart? launchd'sKeepAlivemight auto-handle this -
Credentials/auth: Does the daemon need any env vars or auth tokens that might not be available at boot time?
Feature Request
Would be great to have:
happy daemon install- creates platform-appropriate service filehappy daemon uninstall- removes it- Docs on recommended service setup
Happy to help test or contribute if there's interest!
macOS 15.2, happy-coder 0.13.0