burger
burger

Reputation: 5883

What's the proper way of auto-starting PostgreSQL installed using Homebrew?

The instructions at the end of install provide a solution for starting PostgreSQL when the user logs in:

  cp /usr/local/Cellar/postgresql/9.1.3/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
  launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

I was hoping that if I put the plist in /Library/LaunchAgents/ instead, it would start without waiting for me to log in. Unfortunately, that is not how it works. I haven't found good plist editing instructions and am really afraid of trying to tinker with it. I am guessing the problem lies with the UserName key, but I don't want to remove it and just hope it works.

This is the generated plist:

<?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>homebrew.mxcl.postgresql</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/bin/postgres</string>
    <string>-D</string>
    <string>/usr/local/var/postgres</string>
    <string>-r</string>
    <string>/usr/local/var/postgres/server.log</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>UserName</key>
  <string>my_username</string>
  <key>WorkingDirectory</key>
  <string>/usr/local</string>
  <key>StandardErrorPath</key>
  <string>/usr/local/var/postgres/server.log</string>
</dict>
</plist>

Upvotes: 5

Views: 4540

Answers (1)

kgr
kgr

Reputation: 9948

I would highly recommend using Supervisord. I'm using it on a Mac and it's very nice. If you prefer using PLists though, there is a nice tool called Lingon which is a GUI app for managing those. The new version is not free, but the old one seems to be free and works.

Upvotes: 5

Related Questions