postgres system startup

pedz

Registered
This is my first pass at the two files needed to get postgres to start at boot time. I'm just going to past them into here since they are pretty small.

To use this, create a directory /Library/StartupItems/postmaster

In that directory, put these two files. The postmaster file needs to be executable so do "chmod +x postmaster" (while in the postmaster directory). You do not want the lines with ======'s just the text between.

You may need to alter PGDATA and PG_CTL. These are the default paths.

Finally, to test it you can do:

SystemStarter start postmaster

and

SystemStarter stop postmaster

Enjoy...

postmaster:
=============================================
#!/bin/sh

PGDATA=/usr/local/pgsql/data
PG_CTL=/usr/local/pgsql/bin/pg_ctl

. /etc/rc.common

StartService()
{
su - postgres -c "$PG_CTL start -D $PGDATA -l $PGDATA/logfile"
}

StopService()
{
su - postgres -c "$PG_CTL stop -D $PGDATA"
}

RestartService()
{
su - postgres -c "$PG_CTL restart -D $PGDATA"
}

RunService "$1"
=============================================

StartupParameters.plist:
=============================================
{
Description = "PostgreSQL Server Process";
Provides = ("postmaster");
Requires = ("NetInfo");
OrderPreference = "None";
Messages =
{
start = "Starting PostgreSQL Server";
stop = "Stopping PostgreSQL Server";
};
}
=============================================
 
Back
Top