forked from thoughtbot/laptop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add idempotent brew_launchctl_restart function
Fixes thoughtbot#260 This is a soft error that occurs when Laptop is run and PostgreSQL isn't currently loaded by `launchclt`, e.g. on the first run of Laptop: Starting Postgres ... /Users/wellmade/Library/LaunchAgents/homebrew.mxcl.postgresql.plist -> /usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist launchctl: Error unloading: homebrew.mxcl.postgresql The fix would probably be to check `launchctl list` to see if the service is already loaded before calling `launchctl unload`. This small added complexity probably justifies a function for running appropriate `launchctl` commands. Homebrew has a strong convention for the naming of `launchd` plists: "homebrew.mxcl.FORMULA_NAME.plist", e.g. "homebrew.mxcl.postgresql.plist" and "homebrew.mxcl.redis.plist". This likely makes a function to do the `launchctl` work fairly straightforward.
- Loading branch information
Showing
3 changed files
with
30 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
fancy_echo "Ensure LaunchAgents exists ..." | ||
mkdir -p ~/Library/LaunchAgents | ||
|
||
fancy_echo "Starting Postgres ..." | ||
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents | ||
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist >/dev/null | ||
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist >/dev/null | ||
brew_launchctl_restart postgresql |