POSTS

PostgreSQL database automatic launch on OSX 10.6 Snow Leopard

Blog

It took a while to find this, but here’s my solution

Add this file: /Library/LaunchDaemons/org.postgres.launchd.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
<plist version="1.0">
<dict>
    <!-- Following the launchd man page enumeration of keys -->
    <key>Label</key>
      <string>org.postgres.launchd</string>
    <key>Disabled</key>
      <false/>
    <key>UserName</key>
      <string>_pgsql</string>
    <key>GroupName</key>
      <string>_pgsql</string>
    <key>Program</key>
      <string>/usr/local/pgsql/bin/postmaster</string>
      <key>EnvironmentVariables</key>
      <dict>
              <key>PGDATA</key>
              <string>/usr/local/pgsql/data/</string>
      </dict>
    <key>RunAtLoad</key>
      <true/>
</dict>
</plist>

You can then load it and unload it by issuing:

$ sudo launchctl load /Library/LaunchDaemons/org.postgres.launchd.plist
$ sudo launchctl unload /Library/LaunchDaemons/org.postgres.launchd.plist

Now get to making some great Rails stuff!