It seems I can let the server get started automatically when I run PG, but how can I get PG itself to run at system startup so I basically never have to worry about it?
By default, Postgres.app configures itself to start automatically when you login. It does this by creating a "launch agent" file at the following path:
~/Library/Launch Agents/com.postgresapp.Postgres2LoginHelper.plist.
You can also disable or reenable autostart in the Postgres.app preferences.
Note that Postgres.app only starts after you log in. If you want your servers to start at system startup, before you login, I recommend to create a launch daemon that uses pg_ctl to start the server. However, that is an advanced topic, and I don't know much about the details, so I can't really help there.
I think I found a bug then. If the 'hide icon from menu bar' is checked, then it never starts when the computer starts. If I uncheck that box then it works (by starting both the app and the server).
Are you sure that it's broken? When you uncheck the "show in menu bar" setting, Postgres.app should start the servers invisibly in the background on login.
Here's what I did to reproduce:
Make sure settings look like this:




I've flip-flopped the checkbox + restarted 4 times now to make sure there was nothing "residual" or any weirdness which might have 'carried over'. The checkbox definitely affects its ability to restart on login (I have auto-login enabled)

Thanks! I'll see if I can reproduce the issue!
Any luck reproducing by chance?
@9mm I was able to reproduce it, and I think I found the problem. It's a race condition.
The PostgresLoginHelper executable starts the servers asynchronously in the background. When the menu item is enabled, it also launches the PostgresMenuHelper executable (which displays the menu item).
When the menu item is disabled, PostgresLoginHelper terminates immediately after dispatching the start command, so it terminates before the start command has completed.
The simplest solution would be to add a sleep(10) instruction before terminating the login helper (since it doesn't really matter how long it runs).
A cleaner solution would be to start the servers synchronously -- that would also eliminate race conditions when eg. multiple servers are configured to use the same port (by guaranteeing that the first server wins).
Thanks for your bug report!
Hey! I've now rewritten the login helper to start the PostgreSQL server synchronously (ie. wait until it has actually started before exiting)
In my testing, this now works as expected.
Could you download this build and see if it works for you?
https://eggerapps-downloads.s3.amazonaws.com/Postgres-2.0.2-21.dmg
Awesome, will do
works!
Most helpful comment
By default, Postgres.app configures itself to start automatically when you login. It does this by creating a "launch agent" file at the following path:
~/Library/Launch Agents/com.postgresapp.Postgres2LoginHelper.plist.You can also disable or reenable autostart in the Postgres.app preferences.
Note that Postgres.app only starts after you log in. If you want your servers to start at system startup, before you login, I recommend to create a launch daemon that uses pg_ctl to start the server. However, that is an advanced topic, and I don't know much about the details, so I can't really help there.