Ghosts from the Past: PostgreSQL Orphan
At some point in the days of yore on an earlier version of OS X, a past version of me still hung on to using Macports even though Homebrew was already an established way to roll out your software. I did not dare to upgrade and I guess parts of me didn’t want to abandon the FreeBSD heritage that came with Macports. The switch has long been made but every now and then I encounter the odd artefact of those olden days. Recently it’s been PostgreSQL.
Edit: As commenter Clemens pointed out, the orphaned DB installation has not been put there by Macports but must have been installed by other means.
System-wide PostgreSQL takes Precedence
I was completely oblivious to the fact that I might have installed the database
with anything else than
brew install when I installed PostgreSQL v9.3 using
Homebrew. I made it through the upgrade
spiel alright but when
my database adapter presented me with errors complaining about an unknown JSON
extension after a follow-up reboot, I realised that my old 9.1 instance was
sudo ps ax |grep post showed me a low PID, hinting at the fact that it must
have been started quite early in the boot process. Since after so many years, I
still haven’t come to terms with OS X’ way of configuring startup services
(launchctl, plist, Start Up Items managed per user via the GUI, … – can we just
/etc/init.d please?) I postponed the problem for several weeks.
SIGTERM‘ing the instance and doing a
postgres -D /usr/local/var/postgres
fixed the problem easy enough, but today I finally sat down and fixed it.
Disabling automatic Launch of PostgreSQL in /Library/*
brew info gives you the location and command to auto-start the Homebrew
version. All the symlinks were there and a
launchctl list |grep post showed
me that it was properly hooked up. Since Macports installed everything
systemwide, I did the same as superuser:
launchctl list |grep post gave me
Having no idea where the corresponding .plist file was located I did a fuzzy search
sudo find /Library/ -name \*com.edb.launchd.postgresql-9.1\* and it yielded
/Libary/LaunchDaemons/com.edb.launchd.postgresql-9.1.plist. Finally a
sudo launchctl unload -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.1.plist removed
the old PostgreSQL from starting automatically.