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>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With