mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
(Now featuring documentation: fixed some typos, expanded the
Envrironment and Files section, explained exactly what -w does) This is a patch which allows pg_ctl to make an intelligent guess as to the proper port when running 'psql -l' to determine if the database has started up (the -w flag). The environment variable PGPORT is used. If that is not found, it checks if a specific port has been set inside the postgresql.conf file. If it is has not, it uses the port that Postgres was compiled with. Greg Sabino Mullane greg@turnstep.com
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Copyright (c) 1999, PostgreSQL Global Development Group
|
||||
#
|
||||
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Makefile,v 1.10 2000/11/25 17:17:30 petere Exp $
|
||||
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Makefile,v 1.11 2003/03/20 05:00:14 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -17,6 +17,7 @@ all: pg_ctl
|
||||
pg_ctl: pg_ctl.sh
|
||||
sed -e 's/@VERSION@/$(VERSION)/g' \
|
||||
-e 's,@bindir@,$(bindir),g' \
|
||||
-e 's,@DEF_PGPORT@,$(DEF_PGPORT),g' \
|
||||
$< >$@
|
||||
chmod a+x $@
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.31 2003/02/14 22:18:25 momjian Exp $
|
||||
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.32 2003/03/20 05:00:14 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -60,6 +60,7 @@ Try '$CMDNAME --help' for more information."
|
||||
# Placed here during build
|
||||
bindir='@bindir@'
|
||||
VERSION='@VERSION@'
|
||||
DEF_PGPORT='@DEF_PGPORT@'
|
||||
|
||||
# protect the log file
|
||||
umask 077
|
||||
@@ -240,6 +241,7 @@ fi
|
||||
DEFPOSTOPTS=$PGDATA/postmaster.opts.default
|
||||
POSTOPTSFILE=$PGDATA/postmaster.opts
|
||||
PIDFILE=$PGDATA/postmaster.pid
|
||||
CONFFILE=$PGDATA/postgresql.conf
|
||||
|
||||
if [ "$op" = "status" ];then
|
||||
if [ -f "$PIDFILE" ];then
|
||||
@@ -356,12 +358,6 @@ if [ "$op" = "start" -o "$op" = "restart" ];then
|
||||
fi
|
||||
fi
|
||||
|
||||
# wait for postmaster to start
|
||||
if [ "$wait" = yes ];then
|
||||
cnt=0
|
||||
$silence_echo $ECHO_N "waiting for postmaster to start..."$ECHO_C
|
||||
while :
|
||||
do
|
||||
# FIXME: This is horribly misconceived.
|
||||
# 1) If password authentication is set up, the connection will fail.
|
||||
# 2) If a virtual host is set up, the connection may fail.
|
||||
@@ -369,12 +365,26 @@ if [ "$op" = "start" -o "$op" = "restart" ];then
|
||||
# may fail.
|
||||
# 4) When no Unix domain sockets are available, the connection will
|
||||
# fail. (Using TCP/IP by default ain't better.)
|
||||
# 5) When a different port is configured, the connection will fail
|
||||
# or go to the wrong server.
|
||||
# 6) If the dynamic loader is not set up correctly (for this user/at
|
||||
# 5) If the dynamic loader is not set up correctly (for this user/at
|
||||
# this time), psql will fail (to find libpq).
|
||||
# 7) If psql is misconfigured, this may fail.
|
||||
if "$PGPATH/psql" -l >/dev/null 2>&1
|
||||
# 6) If psql is misconfigured, this may fail.
|
||||
|
||||
# Attempt to use the right port
|
||||
# Use PGPORT if set, otherwise look in the configuration file
|
||||
if [ -z $PGPORT ];then
|
||||
PGPORT=`sed -ne 's/^[ ]*port[^=]*=[ ]\+\([0-9]\+\).*/\1/p' $CONFFILE 2>/dev/null`
|
||||
if [ -z $PGPORT ];then
|
||||
PGPORT=$DEF_PGPORT
|
||||
fi
|
||||
fi
|
||||
|
||||
# wait for postmaster to start
|
||||
if [ "$wait" = yes ];then
|
||||
cnt=0
|
||||
$silence_echo $ECHO_N "waiting for postmaster to start..."$ECHO_C
|
||||
while :
|
||||
do
|
||||
if "$PGPATH/psql" -p $PGPORT -l >/dev/null 2>&1
|
||||
then
|
||||
break;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user