brew services: where to edit configuration?

Viewed 25612

Brew services has installed this plist file for mysql.

~ $ brew services list
Name    Status  User      Plist
mysql56 started mh /Users/mh/Library/LaunchAgents/homebrew.mxcl.mysql56.plist

Is this file safe to edit (i.e. will brew ever overwrite changes made here)? Is there another method I should use to modify the file?

5 Answers
  1. Copy /Users/mh/Library/LaunchAgents/homebrew.mxcl.mysql56.plist somewhere
  2. make changes to copy of plist
  3. run brew services start mysql56 {path to modified copy of plist file}

Update 2022 - for newer versions:

  1. run brew services start mysql56 --file=path to modified copy of plist file

Short answer:

Edit the configuration in usr/local/Cellar/ + name of the Formula / + .plist file

NOT in the file listed next to the daemon in brew services listing


Long answer:

When you install a Formula, its plist file lands in usr/local/Cellar, in a dir named after the formula.

When you spawn a daemon with brew services start, this file is then copied to the running user's Library/LaunchAgents/, e.g.:

for root, it's Library/LaunchAgents/

for a normal user - ~/Library/LaunchAgents

This is important, there is no point in changing this file, it's just a copy that will be overwritten next time you run the service as this user.

However, you can examine this file to see what configuration was used for this particular instance of the service.

When you install a package with Homebrew formula
a .plist file is placed in the package folder
(usually /usr/local/Cellar/... folder)

in OSX this file is copyed/deleted to/from the

/Library/LaunchDaemons/

folder every time tou start/stop the service with Homebrew:

brew services start <the-app>
brew services stop  <the-app>

Better then 'blocking' this file
is acting over the file in your package folder...

this example is for OSX/Mojave & MariaDB:
suppose you want to change the default data folder
and the TCP port from 3306 to 3308

edit the

/usr/local/Cellar/mariadb/10.4.6_1/homebrew.mxcl.mariadb.plist

locate this section in the XML
make you desired changes (choose you desired folder):

...
<string>/usr/local/opt/mariadb/bin/mysqld_safe</string>
<string>--datadir=/DAT/mariadb</string>     
<string>--port=3308</string> 
...

then just stop and restart the service with Homebrew
et voilá... you can use netsat to confirm:

netstat|grep 3308 
Related