brew services && brew bundle

Stefan Hoffmann
<pretty/code>
Published in
2 min readSep 24, 2016

Homebrew recently reached version 1.0 and now also support “brew bundle” and “brew services”.

brew services

brew services is a wrapper around launchctl and helps you to easily manage background services that are installed by Homebrew.

To see all available background services type “brew services list”:

Output of “brew services list”

You can start, stop or restart a service with:

brew services start|stop|restart <service>

When you add “sudo” in front of the command it will run the service as “root” user and also will automatically start the service on system boot.

Starting the mysql service as root

Before version 1.0 to start or stop the service (e.g. MySQL) you needed to execute these commands:

$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Now you can do this by just one easy command.

brew bundle

brew bundle is like Bundler for Homebrew.

So for example when you have a project that requires MySQL 5.6, Redis and Memcached you can list these dependencies in a Brewfile:

tap ‘homebrew/versions’
brew ‘mysql56’, start_service: true, conflicts_with: [‘mysql’]
brew ‘redis’, start_service: true
brew ‘memcached’, start_service: true

When another developer now wants to work on this project, he just have to type “brew bundle” and all dependencies will be installed and started.

Output of “brew bundle”

The “conflicts_with” parameter is neccessary when you also have installed the latest MySQL-Version on your system. brew bundle will then stop and unlink the conflicting services (here mysql) to avoid install errors.

--

--