[Pljava-dev] Setting environment for postmaster in init scripts

From: whalesuit at bonbon(dot)net (Eric E)
To:
Subject: [Pljava-dev] Setting environment for postmaster in init scripts
Date: 2005-06-10 16:35:53
Message-ID: 42A9C169.8040608@bonbon.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Hi all,
I've been wanting to write up a few points I discovered in the
process of trying to install PL/Java into postgres 7.4.

First, the easiest way to set LD_LIBRARY_PATH is by adding the paths to
/etc/ld.so.conf, then running ldconfig. More on why below.

I use Suse 9.x, which, like RedHat and others, uses system of init
scripts (Sys V style, I believe) to start services automatically on load.

When you install Suse binaries (rpm's) for Postgres, an script is
installed into /etc/init.d/postgresql to control startup. The script
(under Suse) sources the file /etc/sysconfig/postgresql, which you can
use to set the CLASSPATH variable.

Within /etc/init.d/postgresql, a function called pg_ctl is defined,
containing the variable CMD. CMD is later executed inside an su
command, which retains all environment variables EXCEPT those beginning
with LD_ . This is a security measure, to avoid pointing to non-system
libraries in su commands.

Therefore a postmaster process started by this script will only
recognize LD_LIBRARY path set either via ld.so.conf, or by changing the
function pg_ctl to include an export statement before the command text:

pg_ctl () {
CMD="/usr/bin/pg_ctl $@ --lsb"
su - postgres -c " export LD_{add variables here} {and here};$CMD"
}

In my case, I ended up putting put all relevant variables inside this
command:

pg_ctl () {
CMD="/usr/bin/pg_ctl $@ --lsb"
su - postgres -c " export
LD_PRELOAD=/usr/lib/jvm/java/jre/lib/i386/libz
ip.so
LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client
CLASSPATH=/usr/lib/postgresql/pljava/pljava.jar;$CMD"
}

This makes the postmaster aware of all variables describe in the PL/JAVA
1.1 setup document.

I hope this is helpful.

Cheers,

Eric

Browse pljava-dev by date

  From Date Subject
Next Message Eric E 2005-06-10 16:55:16 [Pljava-dev] Re: PL/Java example queries don't respond
Previous Message Jamel GASMI 2005-06-10 11:02:02 [Pljava-dev] pljava deploy