What is the correct way to automatically start PostgreSQL using Homebrew?

The instructions at the end of the installation provide a solution for starting PostgreSQL when a 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 enter. Unfortunately, this is not how it works. I have not found good plist editing instructions and am really afraid to try to work with it. I assume that the problem is with the UserName key, but I do not want to delete it and I hope this works.

This is a 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>
+5
source share
1 answer

Supervisord. Mac, . , PLists, Lingon, . , , , .

+5

All Articles