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
thefile(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
Youmiss 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.peder@infoset.cz
End is marked
# [E] added by daniel.peder@infoset.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.peder@infoset.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.peder@infoset.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@infoset.cz
Daniel Peder
http://shop.culture.cz