I'm using the script file included with the postgresql distribution:

***********************************************************************

# PGVERSION is:
PGVERSION=7.1.2

# Source function library.
INITD=/etc/rc.d/init.d
. $INITD/functions

# Get function listing for cross-distribution logic.
#TYPESET=`typeset -f|grep "declare"`

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
# Pretty much need it for postmaster.
[ "${NETWORKING}" = "no" ] && exit 0

[ -f /usr/bin/postmaster ] || exit 0


start(){
        PSQL_START=$"Starting postgresql service: "
        
        export PGDATA=/var/lib/pgsql/data
        if [ ! -d $PGDATA/base ]
        then
        # Check version of existing PGDATA


        # No existing PGDATA! Initdb it.

                echo -n $"Initializing database: "
                if [ ! -d $PGDATA ]
                then
                        mkdir -p $PGDATA
                        chown postgres.postgres $PGDATA
                fi
                # Make sure the locale from the initdb is preserved for
later startups...
                [ -f /etc/sysconfig/i18n ] && cp /etc/sysconfig/i18n
$PGDATA/../initdb.i18n
                # Just in case no locale was set, use en_US
                [ ! -f /etc/sysconfig/i18n ] && echo "LANG=en_US" >
$PGDATA/../initdb.i18n 
                # Is expanded this early to be used in the command su runs
                echo "export LANG LC_ALL LC_CTYPE LC_COLLATE LC_NUMERIC
LC_CTYPE LC_TIME" >> $PGDATA/../initdb.i18n
                # Initialize the database
                su -l postgres -s /bin/sh -c "/usr/bin/initdb
--pgdata=/var/lib/pgsql/data > /dev/null 2>&1" < /dev/null
                [ -f $PGDATA/PG_VERSION ] && echo_success
                [ ! -f $PGDATA/PG_VERSION ] && echo_failure
                echo
        fi

        # Check for postmaster already running...
        pid=`pidof -s postmaster`
        if [ $pid ]
        then
                echo $"Postmaster already running."
        else
                #all systems go -- remove any stale lock files
                rm -f /tmp/.s.PGSQL.* > /dev/null
                echo -n "$PSQL_START"
                su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl  -D $PGDATA -p
/usr/bin/postmaster start  > /dev/null 2>&1" < /dev/null
                sleep 1
                pid=`pidof -s postmaster`
                if [ $pid ]
                then
                        echo "  [ OK ]"
                        touch /var/lock/subsys/postgresql
                        echo $pid > /var/run/postmaster.pid
                        echo
                else
                        echo " [ FAILED ]"
                        echo
                fi
        fi
}

stop(){
        echo -n $"Stopping postgresql service: "
        # Check for older PGDATA location.
                export PGDATA=/var/lib/pgsql/data

        su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl stop -D $PGDATA -s -m
fast" > /dev/null 2>&1
        ret=$? # This will always be 0, as the return code doesn't
propagate... Fix that some day.
        if [ $ret -eq 0 ]; then
            echo_success
        else
            echo_failure
        fi
        echo
        rm -f /var/run/postmaster.pid
        rm -f /var/lock/subsys/postgresql
}

restart(){
    stop
    start
}

condrestart(){
    [ -e /var/lock/subsys/postgresql ] && restart || :
}


# This script is slightly unusual in that the name of the daemon
(postmaster)
# is not the same as the name of the subsystem (postgresql)

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status postmaster
        ;;
  restart)
        restart
        ;;
  condrestart)
        condrestart
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart}"
        exit 1
esac

exit 0
****************************************************************************
***



-----Original Message-----
From: Ryan Mahoney [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 18, 2001 12:43 PM
To: Debra LaVille; [EMAIL PROTECTED]
Subject: Re: Intermittent Startup Failures


There may be some errors in the script that's loads postgres at 
startup.  Look in the "/etc/rc.d/init/" directory and see if there is an 
executable named postgres or something similar.  If so, post the source of 
this file to the group so we can take a look.

Good Luck!

-Ryan Mahoney

At 10:22 AM 7/18/01 -0700, Debra LaVille wrote:

>I have users experiencing problems with PostgreSQL failing to start up
>consistently when their machines reboot. (The reboot may or may not be a
>result of a machine lockup.) No messages have been logged to the
>/var/log/messages file other than "startup failed", but executing the
>startup script by hand then successfully starts PostgreSQL. I have also
seen
>the "starup failed" message displayed on reboot, logged to the messages
>file, but when I checked, postmaster acually is running and I was able to
>start psql. I'm not a script file or Linux guru, but need to get to the
>bottom of this problem. Sorry I cannot provide more data, but any
>suggestions to help me debug this problem would be appreciated. BTW, I'm
>using PostgreSQL 7.1 with Linux 7.0.
>
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/users-lounge/docs/faq.html
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.251 / Virus Database: 124 - Release Date: 4/26/01

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to