postgres init script things solved

From: "Claudiu Balciza" <cbalciza(at)mail(dot)geocities(dot)com>
To: "pgsql hackers" <pgsql-hackers(at)hub(dot)org>, "pgsql questions" <pgsql-questions(at)hub(dot)org>
Subject: postgres init script things solved
Date: 1998-04-07 08:26:23
Message-ID: 01bd61fe$d95118c0$0300010a@claudiu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The postgresql-?.?.?/contrib/linux/postgres.init is meant to start your
postmaster at boot time and stop it at halt/reboot. Excelent.
But it is made for postgres account running tcsh. I know nothing about tchs
and my postgres account defaults to bash. So (thanks to Steve "Stevers!"
Coile) I changed it to bash:
-----------------------------------------------------
if [ ${USE_SYSLOG} = "yes" ]; then

su - ${PGACCOUNT} -c "(${POSTMASTER} ${PGOPTS} 2>&1 | logger -p
${FACILITY}.notice) &" > /dev/null 2>&1 &

else

su - ${PGACCOUNT} -c "${POSTMASTER} ${PGOPTS} 2>>&1 ${PGLOGFILE} &" >
/dev/null 2>&1 &

fi

-----------------------------------------------------
cool, but there was another problem. The script wouldn't stop the postmaster
at halt/reboot while it worked just fine if manually invoked. (RedHat 5.0
sysV init)

Meanwhile I leafed some shell programming book and things cleared up a bit.

In the /etc/rc.d/rc file (the one to start/stop services), the 'stop'
branch, there is a section meant to check if subsystems are up.

-----------------------------------------------------
# Check if the subsystem is already up.
subsys=${i#/etc/rc.d/rc$runlevel.d/K??}
[ ! -f /var/lock/subsys/$subsys ] && \
[ ! -f /var/lock/subsys/${subsys}.init ] && continue
-----------------------------------------------------
That's it, if there's no file named exactly after the symlink (without K??)
in /var/lock/subsys, then it decides the subsystem is not up and gracefully
exits.

If you look in /etc/rc.d/init.d/postgres.init (copy of
postgresql-?.?.?/contrib/linux/postgres.init), you'll find:

-----------------------------------------------------
# touch /var/lock/subsys/${POSTMASTER}
-----------------------------------------------------
which is equally commented and wrong for that kind of init. It should be:

-----------------------------------------------------
# use the name of the symlink without [KS]??

touch /var/lock/subsys/postgres
-----------------------------------------------------
I use:

K05postgres -> /etc/rc.d/init.d/postgres.init on runlevel 1

K05postgres -> /etc/rc.d/init.d/postgres.init on runlevel 6

S98postgres -> /etc/rc.d/init.d/postgres.init on runlevel 3

Claudiu

Attachment Content-Type Size
postgres.init application/octet-stream 1.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Martin 1998-04-07 10:54:13 Re: [HACKERS] Open 6.3.1 issues
Previous Message The Hermit Hacker 1998-04-07 06:00:02 Re: [HACKERS] Developer setup, what works?