Last Updated: February 25, 2016
·
22.56K
· jodosha

Mac Homebrew start/stop services

I constantly switch from a project to another, even multiple times per day, and each of them has a different set of services needed to run (eg. databases, queues). To remember all the paths and the options needed by each of them it's almost impossible, and it will slow down the time-to-code, so I submitted this pull request: https://github.com/mxcl/homebrew/pull/11581

Basically, it adds brew start/stop command, both for foreground and background processes. Unfortunately that patch requires an amend of all the existing recipes and the change of the Formula interface, with the add of #start_command and #stop_command. That causes the patch to be still pending and I don't think it will be approved.

Apparently, there is another way to achieve this goal: brew sub-commands.
The homebrew architecture is pluggable, so if you have in your $PATH an executable (chmod +x) script called brew-services.rb it adds a services sub-command. I have put this in my ~/bin https://gist.github.com/2365430 and my tmux scripts are using it in this way:

brew services restart postgres
brew services restart redis

Happy coding!

2 Responses
Add your response

I want to run two redis instance from brew service but on different ports, i was able to get the default how would i specify the brew to run/pick different redis config to start as service.

Thank you in advance.

over 1 year ago ·

Can't believe brew services is getting dumped :(

over 1 year ago ·