brew services: where to edit configuration?

雨燕双飞 提交于 2019-12-31 08:36:06

问题


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?


回答1:


All .plist files that come with Formulas can be found in Cellar dir. For instance homebrew.mxcl.mysql.plist is in /usr/local/Cellar/mysql/5.7.14. You can modify it and  brew services will use it.

Alternatively you can modify /Library/LaunchDaemons/homebrew.mxcl.mysql.plist and make it immutable with sudo chflags uchg /Library/LaunchDaemons/homebrew.mxcl.mysql.plist. This won't allow brew to rewrite or modify .plist file.




回答2:


I (unfortunately) don't know which file you can edit, but I can confirm that editing anything in the Library/LaunchAgents directory will be overwritten by brew services on the next start, so editing it directly isn't going to help.




回答3:


  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}



回答4:


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 


来源:https://stackoverflow.com/questions/36089384/brew-services-where-to-edit-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!