Skip to content

Automate the creation of a server #714

Open

Description

@orf

Hello,
I'm wondering if there is a way to automate the creation of a Postgres.app managed database server? It would be very handy when setting up new developer machines to be able to also create a Postgres.app server for them. Right now you can obviously run initdb via a shell script, but it's not possible to fully automate the "create a new server" action and have the server appear in the sidebar.

Activity

  1. jakob commented on Apr 19, 2023

    @jakob
    Member

    The servers are stored in the user defaults, so you can just use the defaults write com.postgresapp.Postgres2 .... command to programmatically add it to the sidebar.

    There's no official docs, but it should be pretty self-explanatory. If it's unclear, feel free to post follow up questions.

    The Postgres.app GUI reads the user defaults on launch, so make sure to quit the app before making changes.

  2. orf commented on Apr 19, 2023

    @orf
    Author

    Yeah I saw this, but you may wish for the server to be running before you take a next step. If you're bootstrapping a machine or project with some dependencies from homebrew(such as this one), the next steps may require a Postgres.app server to be running and available. It's minor, but it's a bit annoying to block that and say "now go to this UI and press a few buttons".

    If you're not against it then I could take a stab at adding an additional AppleScript interface to do this, perhaps? I've got the start of a branch here that adds a create server command with a paramater and inits/starts the server.

  3. jakob commented on Apr 19, 2023

    @jakob
    Member

    You can already start/stop servers without using the GUI -- all the GUI does is call pg_ctl.

    But adding AppleScript actions does sound useful! I just did a cursory glance at you branch -- the first thing that jumped out were the try! statements. I assume those are just for testing, but they should be replaced by proper error handling (the error should be reported back to Apple Script).

    One caveat with Apple Script is that macOS recently started showing permission dialogs when you try automating an app for the first time, and I haven't found a way around that yet. (But I haven't looked into it yet in detail)

  4. jakob commented on Nov 6, 2025

    @jakob
    Member

    @orf We have been discussing this issue and realised that you have deleted your fork. Is there any chance you still have a copy of your work somewhere on a backup?

  5. orf commented on Nov 8, 2025

    @orf
    Author

    Unfortunately not @jakob, sorry! I cleaned out my forks a while back and this must have got swept up in that.

    Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions