Re: question about /etc/init.d/postgresql in PGDG - Mailing list pgsql-general

From Greg Smith
Subject Re: question about /etc/init.d/postgresql in PGDG
Date
Msg-id alpine.GSO.2.01.0908191247090.2700@westnet.com
Whole thread Raw
In response to Re: question about /etc/init.d/postgresql in PGDG  (Scott Marlowe <scott.marlowe@gmail.com>)
List pgsql-general
On Wed, 19 Aug 2009, Scott Marlowe wrote:

> The only reason I noticed it was that I was building a server with a
> separate /data partition for the db to live in, and went to edit
> /etc/init.d/postgresql and was faced with two PGDATA assignments...  I
> too deleted the entire if else block when faced with it.

You should never edit that script, because then you'll be stuck resolving
conflicts if you upgrade and the packager makes a change to it to fix a
bug or something like that.  If you want to relocate PGDATA, you should
change /etc/sysconfig/pgsql/postgresql instead and put your local
customizations there.  That file is overlaid on top of the defaults just
after they're set:

   # Override defaults from /etc/sysconfig/pgsql if file is present
   [ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}

What I do is put *all* the defaults into that file, so that there's no
confusion about which version I'm using.

$ cat /etc/sysconfig/pgsql/postgresql
PGENGINE=/usr/bin
PGPORT=5432
PGDATA=/var/lib/pgsql/data
PGLOG=/var/lib/pgsql/pgstartup.log

The nice side-effect of this is that it makes it easy to set all these
values in a user's login profile, so that you can do things like run
pg_ctl manually instead of using the init scripts as root.  Put something
like this in your profile:

. /etc/sysconfig/pgsql/postgresql
export PGDATA PGPORT PGLOG
export PATH="$PGENGINE:$PATH"

And then cycling the engine as the postgres user is as easy as:

pg_ctl start -l $PGLOG
pg_ctl stop

For my login, I add these two bits as well to make that easier, since I
never use the real start/stop commands anyway:

alias start="pg_ctl -D $PGDATA -l $PGLOG -w start && tail $PGLOG"
alias stop="pg_ctl -D $PGDATA stop -m fast"

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

pgsql-general by date:

Previous
From: "Andrus Moor"
Date:
Subject: Re: index "pg_authid_rolname_index" is not a btree
Next
From: Sam Mason
Date:
Subject: Re: Wich the best way to control the logic of a web application?