postgres startup script modification (Linux RedHat)

From: Daniel Péder <dpeder(at)infoset(dot)cz>
To: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Cc: "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org>
Subject: postgres startup script modification (Linux RedHat)
Date: 1999-09-24 09:45:32
Message-ID: 01BF0682.4F744BC0@Dan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

This modification eleminates the case described below:
If PostgreSQL (probaly with Linux) was shut down wrong way (power off, any other damage, kill, etc... ) it left opened the file(socket) /tmp/.s.PGSQL.5432 . It is found by Postmaster's next start with message:
===
Starting postgresql service: FATAL: StreamServerPort: bind() failed: errno=98
Is another postmaster already running on that port?
If not, remove socket node (/tmp/.s.PGSQL.<portnr>)and retry.
/usr/bin/postmaster: cannot create UNIX stream port
===
so, You are in situation that Linux was completely started, all services are running ok except the postgres - and if You miss it, Your server can be running hours without poperly serving the database.

= = = = =

If You find it usefull, make following modification to the file:

/etc/rc.d/init.d/postgresql

on Your RedHat Linux (other Linux or Unix versions will probably need some changes in locations, filenames etc...)
Begin of the changed lines is marked
# [B] added by daniel(dot)peder(at)infoset(dot)cz
End is marked
# [E] added by daniel(dot)peder(at)infoset(dot)cz

other text stuff was left for Your better orientation where put the changes...

so here we are:
======================================================
#!/bin/sh
...
...
[ -f /usr/bin/postmaster ] || exit 0

# See how we were called.
case "$1" in
start)
# [B] added by daniel(dot)peder(at)infoset(dot)cz
echo -n "Checking status of last postgresql service shutdown: "
psql_socket="/tmp/.s.PGSQL.5432"
if [ -e $psql_socket -a "`pidof postmaster`" = "" ]; then
rm -f $psql_socket
echo "incorrect"
else
echo "correct"
fi
# [E] added by daniel(dot)peder(at)infoset(dot)cz

echo -n "Starting postgresql service: "
su postgres -c '/usr/bin/postmaster -S -D/var/lib/pgsql'
sleep 1
pid=`pidof postmaster`
echo -n "postmaster [$pid]"
touch /var/lock/subsys/postmaster
echo
;;
stop)
echo -n "Stopping postgresql service: "
killproc postmaster
sleep 2
rm -f /var/lock/subsys/postmaster
echo
;;...
...
======================================================

--

dpeder(at)infoset(dot)cz
Daniel Peder
http://shop.culture.cz

Browse pgsql-general by date

  From Date Subject
Next Message Teodor Cimpoesu 1999-09-24 10:25:09 Re: [GENERAL] pl/pgsql
Previous Message Adriaan Joubert 1999-09-24 05:23:18 Re: [HACKERS] Re: [GENERAL] Update of bitmask type

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 1999-09-24 09:45:38 RE: [HACKERS] couldn't rollback cache ?
Previous Message Tatsuo Ishii 1999-09-24 06:36:37 Re: [HACKERS] int8 and index