0

I've written a plist file to try to get Postgres to load on startup on Mac OS X but I can't get it to start the service. The plist file is saved in /Library/LaunchDaemons.

    <?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>
            <key>Label</key>
            <string>org.postgres</string>
            <key>UserName</key>
            <string>postgres</string>
            <key>ProgramArguments</key>
            <array>
                <string>/usr/local/pgsql/bin/postgres</string>
                <string>-D/usr/local/pgsql/data</string>
                <string>-l /var/log/pgsql/logfile</string>
            </array>
            <key>RunAtLoad</key>
                <true/>
            <!--The Sockets block was added in an attempt to get it to work but it makes no difference -->
            <key>Sockets</key>
                <dict>
                    <key>Listeners</key>
                    <dict>
                        <key>SockServiceName</key>
                            <string>postgresql</string>
                        <key>SockType</key>
                            <string>stream</string>
                        <key>SockFamily</key>
                            <string>IPv4</string>
                    </dict>
                </dict>
            <key>StandardOutPath</key>
                <string>/var/log/pgsql/psql.log</string>
            <key>StandardErrorPath</key>
                <string>/var/log/pgsql/psql.log</string>
            <key>KeepAlive</key>
                <true/>
        </dict>
    </plist>

The postgres daemon refuses to start and psql.log contains a single line on each attempt: FATAL: SSL is not supported by this build. If I run the postgres executable manually with sudo - u postgres /usr/local/pgsql/bin/postgres -D/usr/local/pgsql/data -l/var/log/psql.log it starts normally. Both the postgres data directory and the logfile and directory are owned by the postgres user.
I built postgres without SSL support due to problems I was having with the build on Max OS X - it's my development machine so doesn't need it.

I added the Sockets entry in the XML after reading through Apple's launchctl docs but it doesn't make any difference. For completeness my /etc/services file has these two entries:

postgresql 5432/udp # PostgreSQL Database

postgresql 5432/tcp # PostgreSQL Database

Mac OS X Catalina

I can't see why launchctl needs SSL to start the service anyway. It seems like launchctl is connecting via a secure socket which is causing my SSL-free installation of postgres to die. Am I correct and if so, it there a way to stop it?

  • That's a question probably more suited for [Apple.SE](https://apple.stackexchange.com). While Postgresql questions are on-topic here on SO, this actually about configuring your macOS to start Postgresql and you might have a better chance at getting an answer on Apple.SE. – DarkDust Oct 26 '22 at 13:20
  • Thanks. I'll remove the postgres tag. – Merely Useful Oct 26 '22 at 13:28
  • Uh, I just noticed: when you try to run it using `sudo` you didn't specify the full path to the `postgres` executable. Run `which postgres`, are you having two different `postgres` binaries? – DarkDust Oct 26 '22 at 16:36
  • I don't think its' the immediate problem, but your `ProgramArguments` array is misformatted. `-D` should be a separate argument from `/usr/local/pgsql/data`, and similarly with `-l` and `/var/log/pgsql/logfile`. – Gordon Davisson Oct 26 '22 at 17:19

0 Answers0