fix: macOS service installer startup issues#44
Merged
Conversation
Fix three issues with the service installer on macOS: 1. Don't use sudo for service stop on macOS. The service is a user LaunchAgent; sudo shifts the home directory to /var/root causing kardianos/service to look for the plist in the wrong location. The stop fails silently, leaving the old service running on the default port, which then forces the port-picker to choose a different port on reinstall. 2. Set RunAtLoad=true in the launchd plist. kardianos/service defaults RunAtLoad to false, so the service wouldn't auto-start after reboot. 3. Only print the listen address after 'service start' when --addr was explicitly provided. Otherwise the output shows the flag default (4242) even though the installed plist may specify a different port.
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.
Fix three issues with the service installer on macOS:
Don't use
sudofor service stop on macOS. The service is a user LaunchAgent;sudoshifts the home directory to/var/root, causing kardianos/service to look for the plist in the wrong location. The stop fails silently, leaving the old service running on the default port, which forces the port-picker to choose a different port on reinstall.Set
RunAtLoad=truein the launchd plist. kardianos/service defaultsRunAtLoadtofalse, so the service wouldn't auto-start after reboot.Only print the listen address after
service startwhen--addrwas explicitly provided. Otherwise the output shows the flag default (4242) even though the installed plist may specify a different port.