I’m having trouble creating a successful daemon. Before PostgreSQL used the @ symbol to specify folder names, there was a working daemon, but now something unknown has changed.
If I run:
sudo -u _systemuser /opt/homebrew/opt/postgresql@14/bin/postgres -D /opt/homebrew/var/postgresql@14
PostgreSQL starts normally.
But this plist doesn’t work.
<?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>Label</key>
<string>homebrew.mxcl.postgresql</string>
<key>RunAtLoad</key>
<true/>
<key>GroupName</key>
<string>_systemuser</string>
<key>UserName</key>
<string>_systemuser</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/postgres</string>
<string>-D</string>
<string>/opt/homebrew/var/postgres</string>
</array>
</dict>
</plist>
LaunchControl says “This operation failed for no apparent reason.”
So, if you enable logging:
<?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>Label</key>
<string>homebrew.mxcl.postgresql14</string>
<key>RunAtLoad</key>
<true/>
<key>GroupName</key>
<string>_systemuser</string>
<key>UserName</key>
<string>_systemuser</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/opt/postgresql@14/bin/postgres</string>
<string>-D</string>
<string>/opt/homebrew/var/postgres@14</string>
</array>
<key>StandardErrorPath</key>
<string>/opt/homebrew/var/log/(email protected)</string>
<key>StandardOutPath</key>
<string>/opt/homebrew/var/log/(email protected)</string>
</dict>
</plist>
I get the error “User _systemuser cannot write to the following file: “file:///opt/homebrew/var/log/(email protected)””.
I changed the permissions on that folder using:
sudo chown -R _systemuser /opt/homebrew/var/postgresql@14
sudo chgrp -R _systemuser /opt/homebrew/var/postgresql@14
However, using this logging plist causes a new error in LaunchControl.
2024-12-26 11:06:02.649106 <Error> Service could not initialize: posix_spawn(/opt/homebrew/opt/postgresql@14/bin/postgres), error 0xd - Permission denied
But as I said at the beginning, PostgreSQL starts fine from the CLI.
Embarrassing situation. Any ideas on what the problem might be?