Autostarting Homebrew Packages
Homebrew has made my life a lot easier when setting up new mac development environments. To install a new package is as easy as typing
brew install mongo on the command line.
Sometimes you want a program to start a daemon (background) process when you log in. For example, I can start mongodb’s daemon with the mongod command, but it’d be nicer if it just started automatically whenever I logged in.
Fortunately Homebrew has a way to do this! Simply type
brew info <package name> (in this case it would be
brew info mongo). If mongo isn’t set up to run automatically, the last bit of output will list the exact command you need to run to start mongo when you log in:
To have launchd start mongodb at login: ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents Then to load mongodb now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist Or, if you don't want/need launchctl, you can just run: mongod
Note that it also shows you the name of mongo’s daemon process, mongod.
(originally posted on my personal blog)