nr5_mg
Last Updated: February 25, 2016
·
8.839K
· jodosha
Avatar white

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!

Say Thanks
Respond

2 Responses
Add your response

14788
6595b0abb87265283a797b178151273b

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 ·
15652
2af4ea9bb6380b59d05d2b9b6d8112e9

Can't believe brew services is getting dumped :(

over 1 year ago ·
Filed Under