I followed the PostgreSQL installation instructions on Apple's site and got PostgreSQL up and running in no time. To make PostgreSQL start when MacOS starts, I had to do a little more work. I added a startup item as described in James Duncan Davidson's Running Mac OS X Panther. First, I created a startup item directory and used vi to create a parameters file:
root# mkdir -p /Library/StartupItems/PostgreSQL root# cd /Library/StartupItems/PostgresSQL root# vi StartupParameters.plist
Next, I guessed that PostgreSQL requires Directory Services and uses Disks and came up with this StartupParameters.plist file:
{
Description = "PostgreSQL Server";
Provides = ("PostgreSQL");
Requires = ("DirectoryServices");
Uses = ("Disks");
OrderPreference = "None";
}
Finally, I wrote a startup script to start, restart, and stop PostgreSQL:
#!/bin/sh
. /etc/rc.common
StartService() {
echo "Starting PostgreSQL"
sudo -u postgres /usr/local/pgsql/bin/postmaster -i -D /var/postgres/rollerdb &
}
RestartService() {
echo "Restarting PostgreSQL"
sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /var/postgres/rollerdb stop
sudo -u postgres /usr/local/pgsql/bin/postmaster -i -D /var/postgres/rollerdb &
}
StopService() {
echo "Stopping PostgreSQL"
sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /var/postgres/rollerdb stop
}
RunService "$1"
Once I was done with that I tested starting, restarting, and stopping PostgreSQL using the SystemStarter command. Once the script worked, I rebooted and found that PostgreSQL did indeed start on startup. It works, but I wonder, is this the best way to configure service for Mac OS X? Davidson's book menioned xinetd and mach bootstrap servers, but says that the SystemStarter is the way to go for now.
This work is licensed under a Creative Commons License.
Copyright 2002-2007, David M Johnson (dave.johnson at rollerweblogger.org)
This is a personal weblog, I do not speak for my employer.

Buy now from Amazon.com
Or direct from Manning
| « December 2008 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | |||
| Today | ||||||
Allen Gilliland
Anil Gangolli
Dan Axon
Danese Cooper
Film Babble Blog
Geertjan's Weblog
Henri Yandell
James Robertson
Jim Grisanzio
Josh Staiger
Linda Skrocki
Pat Chanezon
Rama
Ruby Sinreich
Simon Phipps
Tim Bray
Will Snow
Janne Jalkanen
Joe Gregorio
Matt Raible
Mike Cannon Brookes
Rafe Colburn
Sam Ruby
Simon Brown
My other sites
Posted by Jon Mountjoy on May 26, 2004 at 03:15 AM EDT #
Posted by Robert Sfeir on May 26, 2004 at 07:49 AM EDT #
Posted by arturo on May 26, 2004 at 10:59 AM EDT #
Posted by Ted on May 26, 2004 at 07:40 PM EDT #
Posted by Ted on May 27, 2004 at 01:13 PM EDT #