postgres startup script modification (Linux RedHat) - Mailing list pgsql-hackers

From Daniel Péder
Subject postgres startup script modification (Linux RedHat)
Date
Msg-id 01BF06B1.E09B10A0@Dan
Whole thread Raw
List 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
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
runningon 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
serviceshutdown: "       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]
addedby daniel.peder@infoset.cz
 
       echo -n "Starting postgresql service: "       su postgres -c '/usr/bin/postmaster -S -D/var/lib/pgsql'
sleep1       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
€€



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] int8 and index
Next
From: Adriaan Joubert
Date:
Subject: Re: [HACKERS] Re: [GENERAL] Update of bitmask type