services
era um comando "oculto" no Homebrew. Havia um monte deles que não estavam presentes nobrew help
saída. Como os comandos não documentados costumam fazer, desapareceu no repositório oficial e se tornou um " comando externo " mantido em outro repositório de complementos (neste caso, uma essência, pois é tão simples).
Você pode instalá-lo na configuração do Homebrew executando:
> curl -o /usr/local/bin/brew-services.rb https://gist.githubusercontent.com/lwe/766293/raw/75a7907004bbff0eb3b072d1d951be2cfe7e5020/brew-services.rb
> chmod +x /usr/local/bin/brew-services.rb
> brew services help
usage: [sudo] brew services [--help] <command> [<formula>]
Small wrapper around `launchctl` for supported formulas, commands available:
cleanup Get rid of stale services and unused plists
list List all services managed by `brew services`
restart Gracefully restart selected service
start Start selected service
stop Stop selected service
Options, sudo and paths:
sudo When run as root, operates on /Library/LaunchDaemons (run at boot!)
Run at boot: /Library/LaunchDaemons
Run at login: /Users/ian/Library/LaunchAgents
Como alternativa, você pode pular services
e apenas criar um arquivo plist para ele. Por exemplo, crie ~/Library/LaunchAgents/org.mongodb.mongod.plist
com:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongodb.mongod</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/Cellar/mongodb/2.6.4/bin/mongod</string>
<string>run</string>
<string>--config</string>
<string>/usr/local/Cellar/mongodb/2.6.4/mongod.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>UserName</key>
<string>{your_username}</string>
<key>WorkingDirectory</key>
<string>/usr/local</string>
<key>StandardErrorPath</key>
<string>/usr/local/var/log/mongodb/output.log</string>
<key>StandardOutPath</key>
<string>/usr/local/var/log/mongodb/output.log</string>
</dict>
</plist>
Apenas mude {your_username}
para o seu nome de usuário real e execute:
launchctl load ~/Library/LaunchAgents/org.mongodb.mongod.plist
para registrar o plist no launchd. Agora você pode iniciar e parar o MongoDB com:
launchctl start org.mongodb.mongod
launchctl stop org.mongodb.mongod
Observe que a solução anterior foi extraída dessa excelente resposta do Stack Overflow .