Skip to content

Instantly share code, notes, and snippets.

@jimeh
Created March 24, 2011 10:47
Show Gist options
  • Save jimeh/884869 to your computer and use it in GitHub Desktop.
Save jimeh/884869 to your computer and use it in GitHub Desktop.
Mac OS X launchctl plist for Homebrew-based RabbitMQ installations. Place in: ~/Library/LaunchAgents
<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.rabbitmq.rabbitmq-server</string>
<key>Program</key>
<string>/usr/local/sbin/rabbitmq-server</string>
<key>RunAtLoad</key>
<true/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/sbin:/usr/bin:/bin:/usr/local/bin</string>
</dict>
<key>WorkingDirectory</key>
<string>/usr/local/var</string>
</dict>
</plist>
@ArthurN
Copy link

ArthurN commented Apr 22, 2011

If it helps, here's what my system.log showed:

Apr 21 20:06:19 Inception sudo[53039]: arthur : TTY=ttys004 ; PWD=/usr/local/Cellar/rabbitmq/2.0.0/lib/rabbitmq/erlang/lib/rabbitmq-2.0.0 ; USER=root ; COMMAND=/bin/launchctl start com.rabbitmq.rabbitmq-server
Apr 21 20:06:19 Inception com.rabbitmq.rabbitmq-server[53040]: /usr/local/sbin/rabbitmq-server: line 90: erl: command not found
Apr 21 20:06:19 Inception com.apple.launchd[1] (com.rabbitmq.rabbitmq-server[53040]): Exited with exit code: 1

I tried running it as root. I also tried putting it in LaunchAgents and running it at my user level, but still no go. I also didn't feel like spending too much time on this, but if I get really sick of running "rabbitmq-server -detached" by hand I might give it another look.

@jimeh
Copy link
Author

jimeh commented Apr 27, 2011

Fixed it. Works fine now, just remember to replace {{USERNAME}} with your own unix username.

Update: The UserName option is not needed.

@ArthurN
Copy link

ArthurN commented May 2, 2011

Cool, thanks. That does work now. For anyone else that might get the "erlexec: HOME must be set" error, simply add it to your EnvironmentVariables key. Any path should work.

  <key>EnvironmentVariables</key>
  <dict>
    <key>PATH</key>
    <string>/usr/local/sbin:/usr/bin:/bin:/usr/local/bin</string>
    <key>HOME</key>
    <string>/Users/{{USERNAME}}</string>
  </dict>

@maxigs
Copy link

maxigs commented May 24, 2013

2 years later it still works, thanks!

@scottcc
Copy link

scottcc commented Jun 5, 2013

Small note that if you want this to run as a daemon, put it in /Library/LaunchDaemons instead. You may need to use ProgramArguments instead of Program though, man launchctl.plist and man execvp to be sure.

@rgazelot
Copy link

A LaunchAgents must be loaded manually as LaunchDaemons using sudo launchctl load /Library/LaunchAgents/com.rabbitmq.rabbitmq-server.plist ? I made it and it's works perfectly but I don't know if it was necessary. Thanks for the share.

@dalguji
Copy link

dalguji commented Apr 13, 2015

If it's brew-installed, you can try the following instructions instead that you can get by brew info rabbitmq

$ brew info rabbitmq
<snip>

To have launchd start rabbitmq at login:
    ln -sfv /usr/local/opt/rabbitmq/*.plist ~/Library/LaunchAgents
Then to load rabbitmq now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.rabbitmq.plist
Or, if you don't want/need launchctl, you can just run:
    rabbitmq-server

@ramubotsplash
Copy link

2017 - brew options changed and its much simpler now:

$ brew info rabbitmq
<snip>

To have launchd start rabbitmq now and restart at login:
  brew services start rabbitmq
Or, if you don't want/need a background service you can just run:
  rabbitmq-server

@dexterbt1
Copy link

@Aarpy
thanks for this. I was on the same boat scratching my head where the plist are found

@morenoh149
Copy link

morenoh149 commented Aug 31, 2017

@Aarpy that is very useful thanks. But it does not behave the same as I usually do with sudo (sudo rabbitmq-server). Any idea why?

sudo brew services start rabbitmq doesn't work either.
And performing ps aux | grep rabbit doesn't show any processes when using the brew commands, only when I do sudo rabbitmq-server.

Tracking issue Homebrew/homebrew-core#17446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment