You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Login Helper (starts PostgreSQL servers on login, and the menu helper)
Menu Helper (shows the menu bar icon)
The main reason for the helpers is that we don't want to show any user interface on login (dock icon, app window) but still launch servers.
However, I've realised that we could maybe do away with the helpers alltogether by dynamically changing the "activation policy" using NSApp.setActivationPolicy(.regular) and NSApp.setActivationPolicy(.accessory) to show/hide the dock icon.
Then instead of a helper app, we could just launch the main app on login.
if the app is opened as a login item, we call .setActivationPolicy(.accessory)
if the app is opened normally (eg. double clicking in Finder) we call .setActivationPolicy(.regular)
if the main window is closed we call .setActivationPolicy(.accessory)
when the app is terminated (eg. using the "quit" command or when the user logs out) we stop all servers and quit the app
Behavior would be similar to how it is now, but we would only have a single app and no helpers.
Advantages:
app shows up as a normal login item
sparkle check happens every login (doesn't require explicitly launching main app)
no more version conflicts (eg. when a different version of main app vs helper is running)
no more apple script errors when controlling main app from menu helper (it's the same process)
check if Postgres.app is registered as a login item with SMAppService.mainApp.status: the result can be enabled if it is registered as a login item, and notFound if it is not.
we can add/remove the login item with register() and unregister() methods
if the user removes the login item, we can just add it again, but we don't want to add it if the user removed it. We should probably store the setting in user defaults, or automatically add it only once and don't re-add it if the user manually removed it
We can use the LSSharedFileListSessionLoginItems API to do exactly the same thing on macOS 11 and macOS 12. These APIs are officially deprecated since 10.11, but they still work on macOS 26. Calling the deprecated API from Swift is not easy, so I will probably just write a simple Objective C helper class.
The dialog is shown only when using Cmd-Q (or selecting "Quit" from the "Postgres" menu). There is no confirmation when selecting "Quit" from the menu bar icon. This is what I would personally expect, and it is also similar to the existing behavior.
Suggestions for better text in the alert are welcome :)
I did some testing on the macOS 27 beta. Apple improved the background activities toggle so that it also applies to login item. Adding a login item automatically enables the background activities setting.
So I think maybe we should just use .loginItem? Using .mainApp is confusing, since that effectively just adds another way for users to disable background activities (remove from login items, turn off the background activities toggle, or disable in Postgres.app preferences).
Here's a summary of behavior differences regarding .loginItem vs .mainApp (on macOS 27):
.loginItem
shows "background activity" toggle
when you enable "background activity" the login item is launched immediately
2 ways to disable: deactivate background activity in system settings or deactivate "launch at login" in Postgres.app settings
.mainApp
adds app to "login items"
shows "background activity" toggle. when disabled, the app is not launched even though it appears in login items above
when you enable "background activity", the app is launched at next login
3 ways to disable: deactivate background activity in system settings, remove login item in system settings, or decativate "launch at login" in Postgres.app settings
If you want to test the differences:
3alpha4 uses .mainApp
3alpha5 uses .loginItem
I think I slighly prefer .loginItem, but I am not sure.
A data point for this from macOS 27.0.1 (26A434), with Postgres.app 2.9.6 and PostgreSQL 16.15:
On macOS 27, quitting Postgres.app already stops any server the app started, even though 2.9.6 doesn't do that itself. About a second after the app exits, loginwindow sends the server SIGTERM:
08:32:52.781 Postgres: (AppKit) [com.apple.AppKit:Application] terminate:
08:32:52.803 launchd: [gui/501/application.com.postgresapp.Postgres2…] exited due to exit(0)
08:32:53.899 loginwindow: (libquit.dylib) force quit (caller responsible for termination)
08:32:53.905 loginwindow: (libLaunchServicesSupport.dylib) quitOrKillSubordinateProcesses: Failed to quit or kill application "Postgres", error=-600 procNotFound
08:32:53.910 postgres: LOG: received smart shutdown request
It isn't specific to Postgres.app. Quitting Terminal also stops a gpg-agent that was started from Terminal, and another project reported the same thing: nexu-io/open-design#8276
So on macOS 27, any server the app starts appears to be tied to the app: it stops when the app quits, whatever 3.0 decides. If users should be able to keep servers running without the app, the servers would probably need to be started by launchd (for example, a LaunchAgent or SMAppService.agent) rather than by the app. As a workaround, I now run the server from my own LaunchAgent (postgres -D <data dir>), and it survives quitting the app.
Drafted with Claude (Anthropic's AI assistant) from my own logs and testing.
@dchacke Did you disable App Background Activities for Postgres.app (in System Settings -> General -> Login Items & Extensions)?
If you disable app background activities, then macOS 27 kills postgres processes started by Postgres.app 2.x after you quit the app. (However, when the server is started from the menu item it is not killed -- it is rather confusing)
So if you are using Postgres.app 2.x on macOS 27, please don't turn off app background activities.
Postgres.app 3.0 does not have this limitation, it should work with app background activities turned off as well.
Activity
jakob commentedon May 5, 2026
Technical notes:
On macOS 13 and later we could do the following:
SMAppService.mainApp.status: the result can beenabledif it is registered as a login item, andnotFoundif it is not.register()andunregister()methodsWe can use the
LSSharedFileListSessionLoginItemsAPI to do exactly the same thing on macOS 11 and macOS 12. These APIs are officially deprecated since 10.11, but they still work on macOS 26. Calling the deprecated API from Swift is not easy, so I will probably just write a simple Objective C helper class.jakob commentedon May 6, 2026
Here are some drawbacks / advantages of using
SMAppService.mainAppvsSMAppService.loginItem()SMAppService.mainApp
SMAppService.loginItem
Upgrade considerations
.loginItemto.mainAppmacOS will show a notification (something like "Postgres installed a login item")jakob commentedon May 6, 2026
jakob commentedon May 7, 2026
Todo:
jakob commentedon May 20, 2026
I implemented a dialog in 469f77d
The dialog is shown only when using Cmd-Q (or selecting "Quit" from the "Postgres" menu). There is no confirmation when selecting "Quit" from the menu bar icon. This is what I would personally expect, and it is also similar to the existing behavior.
Suggestions for better text in the alert are welcome :)
jakob commentedon Jun 16, 2026
I did some testing on the macOS 27 beta. Apple improved the background activities toggle so that it also applies to login item. Adding a login item automatically enables the background activities setting.
So I think maybe we should just use
.loginItem? Using.mainAppis confusing, since that effectively just adds another way for users to disable background activities (remove from login items, turn off the background activities toggle, or disable in Postgres.app preferences).jakob commentedon Jun 25, 2026
Here's a summary of behavior differences regarding
.loginItemvs.mainApp(on macOS 27):.loginItem.mainAppIf you want to test the differences:
.mainApp.loginItemI think I slighly prefer
.loginItem, but I am not sure.dchacke commentedon Oct 13, 2026
A data point for this from macOS 27.0.1 (26A434), with Postgres.app 2.9.6 and PostgreSQL 16.15:
On macOS 27, quitting Postgres.app already stops any server the app started, even though 2.9.6 doesn't do that itself. About a second after the app exits, loginwindow sends the server SIGTERM:
It isn't specific to Postgres.app. Quitting Terminal also stops a
gpg-agentthat was started from Terminal, and another project reported the same thing: nexu-io/open-design#8276So on macOS 27, any server the app starts appears to be tied to the app: it stops when the app quits, whatever 3.0 decides. If users should be able to keep servers running without the app, the servers would probably need to be started by launchd (for example, a LaunchAgent or
SMAppService.agent) rather than by the app. As a workaround, I now run the server from my own LaunchAgent (postgres -D <data dir>), and it survives quitting the app.Drafted with Claude (Anthropic's AI assistant) from my own logs and testing.
jakob commentedon Nov 4, 2026
@dchacke Did you disable App Background Activities for Postgres.app (in System Settings -> General -> Login Items & Extensions)?
If you disable app background activities, then macOS 27 kills postgres processes started by Postgres.app 2.x after you quit the app. (However, when the server is started from the menu item it is not killed -- it is rather confusing)
So if you are using Postgres.app 2.x on macOS 27, please don't turn off app background activities.
Postgres.app 3.0 does not have this limitation, it should work with app background activities turned off as well.