pg_ctl -w port detection with docs
pg_ctl -w port detection with docs
От:
"Greg Sabino Mullane" <greg@turnstep.com>
Дата:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message
(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
PGP Key: 0x14964AC8 200302230759
Index: pg_ctl.sh
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/pg_ctl.sh,v
retrieving revision 1.31
diff -c -r1.31 pg_ctl.sh
*** pg_ctl.sh 2003/02/14 22:18:25 1.31
--- pg_ctl.sh 2003/02/22 14:47:09
***************
*** 60,65 ****
--- 60,66 ----
# Placed here during build
bindir='@bindir@'
VERSION='@VERSION@'
+ DEF_PGPORT='@DEF_PGPORT@'
# protect the log file
umask 077
***************
*** 240,245 ****
--- 241,247 ----
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,367 ****
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.
--- 358,363 ----
***************
*** 369,380 ****
# 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
# this time), psql will fail (to find libpq).
! # 7) If psql is misconfigured, this may fail.
! if "$PGPATH/psql" -l >/dev/null 2>&1
then
break;
else
--- 365,390 ----
# may fail.
# 4) When no Unix domain sockets are available, the connection will
# fail. (Using TCP/IP by default ain't better.)
! # 5) If the dynamic loader is not set up correctly (for this user/at
# this time), psql will fail (to find libpq).
! # 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
Index: Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/Makefile,v
retrieving revision 1.10
diff -c -r1.10 Makefile
*** Makefile 2000/11/25 17:17:30 1.10
--- Makefile 2003/02/22 14:47:40
***************
*** 17,22 ****
--- 17,23 ----
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 $@
Index: pg_ctl-ref.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/pg_ctl-ref.sgml,v
retrieving revision 1.18
diff -c -r1.18 pg_ctl-ref.sgml
*** pg_ctl-ref.sgml 2003/01/19 00:13:30 1.18
--- pg_ctl-ref.sgml 2003/02/23 12:56:04
***************
*** 73,94 ****
PostgreSQL backend server, or displaying
the status of a running postmaster. Although the postmaster can be
started manually, pg_ctl encapsulates
! tasks such as redirecting log output, properly detaching from the
! terminal and process group, and it provides convenient options for
controlled shutdown.
In mode, a new postmaster is launched. The
! server is started in the background, the standard input attached to
/dev/null. The standard output and standard
! error are either appended to a log file, if the
! option is used, or are redirected to
! pg_ctl's standard output (not standard
! error). If no log file is chosen, the standard output of
! pg_ctl should be redirected to a file or
! piped to another process, for example a log rotating program,
! otherwise the postmaster will write its output the the controlling
terminal (from the background) and will not leave the shell's
process group.
--- 73,93 ----
PostgreSQL backend server, or displaying
the status of a running postmaster. Although the postmaster can be
started manually, pg_ctl encapsulates
! tasks such as redirecting log output and properly detaching from the
! terminal and process group. It also provides convenient options for
controlled shutdown.
In mode, a new postmaster is launched. The
! server is started in the background, and standard input is attached to
/dev/null. The standard output and standard
! error are either appended to a log file (if the
! option is used), or redirected to pg_ctl's
! standard output (not standard error). If no log file is chosen, the
! standard output of pg_ctl should be redirected
! to a file or piped to another process, for example a log rotating program,
! otherwise the postmaster will write its output to the controlling
terminal (from the background) and will not leave the shell's
process group.
***************
*** 102,109 ****
not wait for clients to disconnect. All active transactions are
rolled back and clients are forcibly disconnected, then the
database is shut down. Immediate mode will abort
! all server processes without clean shutdown. This will lead to a recovery
! run on restart.
--- 101,108 ----
not wait for clients to disconnect. All active transactions are
rolled back and clients are forcibly disconnected, then the
database is shut down. Immediate mode will abort
! all server processes without a clean shutdown. This will lead to
! a recovery run on restart.
***************
*** 121,129 ****
! mode checks whether a postmaster is running
! and if so displays the PID and the command line
! options that were used to invoke it.
--- 120,128 ----
! mode checks whether a postmaster is running.
! If it is, the PID and the command line
! options that were used to invoke it are displayed.
***************
*** 188,194 ****
Specifies the location of the postmaster
executable. By default the postmaster is taken from the same
! directory as pg_ctl</>, or failing that, the hard-wired
installation directory. It is not necessary to use this
option unless you are doing something unusual and get errors
that the postmaster was not found.
--- 187,193 ----
Specifies the location of the postmaster
executable. By default the postmaster is taken from the same
! directory as pg_ctl, or failing that, the hard-wired
installation directory. It is not necessary to use this
option unless you are doing something unusual and get errors
that the postmaster was not found.
***************
*** 210,216 ****
Wait for the start or shutdown to complete. Times out after
! 60 seconds. This is the default for shutdowns.
--- 209,224 ----
Wait for the start or shutdown to complete. Times out after
! 60 seconds. This is the default for shutdowns. A successful
! shutdown is indicated by removal of the PID
! file. For starting up, a successful psql -l
! indicates success. pg_ctl will attempt to
! use the proper port for psql. If the environment variable
! PGPORT exists, that is used. Otherwise, it will see if a port
! has been set in the postgresql.conf file.
! If neither of those is used, it will use the default port that
! PostgreSQL was compiled with
! (5432 by default).
***************
*** 238,247 ****
! Default data direction location
--- 246,265 ----
! Default data directory location.
+
+
+ PGPORT
+
+
+
+ Default port for (used by the -w option).
+
+
+
***************
*** 253,264 ****
Files
!
! If the file postmaster.opts.default exists in
! the data directory, the contents of the file will be passed as
! options to the postmaster, unless
! overridden by the option.
!
--- 271,328 ----
Files
!
!
! postmaster.pid
!
!
! The existence of this file in the data directory is used to help
! pg_ctl determine if the server is
! currently running or not.
!
!
!
!
!
! postmaster.opts.default
!
!
! If this file exists in the data directory,
! pg_ctl (in mode)
! will pass the contents of the file as options to the
! postmaster, unless overridden
! by the option.
!
!
!
!
!
! postmaster.opts
!
!
! If this file exists in the data directory,
! pg_ctl (in mode)
! will pass the contents of the file as options to the
! postmaster, unless overridden
! by the option. The contents of this file
! are also displayed in mode.
!
!
!
!
!
! postgresql.conf
!
!
! This file, located in the data directory, is parsed to
! find the proper port to send to the
! psql when the
! is given in mode.
!
!
!
!
!
***************
*** 268,274 ****
Waiting for complete start is not a well-defined operation and may
fail if access control is set up so that a local client cannot
! connect without manual interaction. It should be avoided.
--- 332,338 ----
Waiting for complete start is not a well-defined operation and may
fail if access control is set up so that a local client cannot
! connect without manual interaction (e.g. password authentication).
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html
iD8DBQE+V0ZkvJuQZxSWSsgRAjA+AJ9eFCNSb3Kr4v8UxzRa+/nKSTg87wCeOtzz
oZlhuzlz19ctvswFMmoXPAo=
=HQEB
-----END PGP SIGNATURE-----
Re: pg_ctl -w port detection with docs
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches I will try to apply it within the next 48 hours. --------------------------------------------------------------------------- Greg Sabino Mullane wrote: [ There is text before PGP section. ] > [ PGP not available, raw data follows ] > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > NotDashEscaped: You need GnuPG to verify this message > > > (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 > PGP Key: 0x14964AC8 200302230759 > > Index: pg_ctl.sh > =================================================================== > RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/pg_ctl.sh,v > retrieving revision 1.31 > diff -c -r1.31 pg_ctl.sh > *** pg_ctl.sh 2003/02/14 22:18:25 1.31 > --- pg_ctl.sh 2003/02/22 14:47:09 > *************** > *** 60,65 **** > --- 60,66 ---- > # Placed here during build > bindir='@bindir@' > VERSION='@VERSION@' > + DEF_PGPORT='@DEF_PGPORT@' > > # protect the log file > umask 077 > *************** > *** 240,245 **** > --- 241,247 ---- > 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,367 **** > 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. > --- 358,363 ---- > *************** > *** 369,380 **** > # 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 > # this time), psql will fail (to find libpq). > ! # 7) If psql is misconfigured, this may fail. > ! if "$PGPATH/psql" -l >/dev/null 2>&1 > then > break; > else > --- 365,390 ---- > # may fail. > # 4) When no Unix domain sockets are available, the connection will > # fail. (Using TCP/IP by default ain't better.) > ! # 5) If the dynamic loader is not set up correctly (for this user/at > # this time), psql will fail (to find libpq). > ! # 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 > Index: Makefile > =================================================================== > RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/Makefile,v > retrieving revision 1.10 > diff -c -r1.10 Makefile > *** Makefile 2000/11/25 17:17:30 1.10 > --- Makefile 2003/02/22 14:47:40 > *************** > *** 17,22 **** > --- 17,23 ---- > 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 $@ > > > > > Index: pg_ctl-ref.sgml > =================================================================== > RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/pg_ctl-ref.sgml,v > retrieving revision 1.18 > diff -c -r1.18 pg_ctl-ref.sgml > *** pg_ctl-ref.sgml 2003/01/19 00:13:30 1.18 > --- pg_ctl-ref.sgml 2003/02/23 12:56:04 > *************** > *** 73,94 **** > PostgreSQL backend server, or displaying > the status of a running postmaster. Although the postmaster can be > started manually, pg_ctl encapsulates > ! tasks such as redirecting log output, properly detaching from the > ! terminal and process group, and it provides convenient options for > controlled shutdown. > > > > In mode, a new postmaster is launched. The > ! server is started in the background, the standard input attached to > /dev/null. The standard output and standard > ! error are either appended to a log file, if the > ! option is used, or are redirected to > ! pg_ctl's standard output (not standard > ! error). If no log file is chosen, the standard output of > ! pg_ctl should be redirected to a file or > ! piped to another process, for example a log rotating program, > ! otherwise the postmaster will write its output the the controlling > terminal (from the background) and will not leave the shell's > process group. > > --- 73,93 ---- > PostgreSQL backend server, or displaying > the status of a running postmaster. Although the postmaster can be > started manually, pg_ctl encapsulates > ! tasks such as redirecting log output and properly detaching from the > ! terminal and process group. It also provides convenient options for > controlled shutdown. > > > > In mode, a new postmaster is launched. The > ! server is started in the background, and standard input is attached to > /dev/null. The standard output and standard > ! error are either appended to a log file (if the > ! option is used), or redirected to pg_ctl's > ! standard output (not standard error). If no log file is chosen, the > ! standard output of pg_ctl should be redirected > ! to a file or piped to another process, for example a log rotating program, > ! otherwise the postmaster will write its output to the controlling > terminal (from the background) and will not leave the shell's > process group. > > *************** > *** 102,109 **** > not wait for clients to disconnect. All active transactions are > rolled back and clients are forcibly disconnected, then the > database is shut down. Immediate mode will abort > ! all server processes without clean shutdown. This will lead to a recovery > ! run on restart. > > > > --- 101,108 ---- > not wait for clients to disconnect. All active transactions are > rolled back and clients are forcibly disconnected, then the > database is shut down. Immediate mode will abort > ! all server processes without a clean shutdown. This will lead to > ! a recovery run on restart. > > > > *************** > *** 121,129 **** > > > > ! mode checks whether a postmaster is running > ! and if so displays the PID and the command line > ! options that were used to invoke it. > > > > --- 120,128 ---- > > > > ! mode checks whether a postmaster is running. > ! If it is, the PID and the command line > ! options that were used to invoke it are displayed. > > > > *************** > *** 188,194 **** > > Specifies the location of the postmaster > executable. By default the postmaster is taken from the same > ! directory as pg_ctl</>, or failing that, the hard-wired > installation directory. It is not necessary to use this > option unless you are doing something unusual and get errors > that the postmaster was not found. > --- 187,193 ---- > > Specifies the location of the postmaster > executable. By default the postmaster is taken from the same > ! directory as pg_ctl, or failing that, the hard-wired > installation directory. It is not necessary to use this > option unless you are doing something unusual and get errors > that the postmaster was not found. > *************** > *** 210,216 **** > > > Wait for the start or shutdown to complete. Times out after > ! 60 seconds. This is the default for shutdowns. > > > > --- 209,224 ---- > > > Wait for the start or shutdown to complete. Times out after > ! 60 seconds. This is the default for shutdowns. A successful > ! shutdown is indicated by removal of the PID > ! file. For starting up, a successful psql -l > ! indicates success. pg_ctl will attempt to > ! use the proper port for psql. If the environment variable > ! PGPORT exists, that is used. Otherwise, it will see if a port > ! has been set in the postgresql.conf file. > ! If neither of those is used, it will use the default port that > ! PostgreSQL was compiled with > ! (5432 by default). > > > > *************** > *** 238,247 **** > > > > ! Default data direction location > > > > > > > --- 246,265 ---- > > > > ! Default data directory location. > > > > + > + > + PGPORT > + > + > + > + Default port for (used by the -w option). > + > + > + > > > > *************** > *** 253,264 **** > > Files > > ! > ! If the file postmaster.opts.default exists in > ! the data directory, the contents of the file will be passed as > ! options to the postmaster, unless > ! overridden by the option. > ! > > > > --- 271,328 ---- > > Files > > ! > ! > ! postmaster.pid > ! > ! > ! The existence of this file in the data directory is used to help > ! pg_ctl determine if the server is > ! currently running or not. > ! > ! > ! > ! > ! > ! postmaster.opts.default > ! > ! > ! If this file exists in the data directory, > ! pg_ctl (in mode) > ! will pass the contents of the file as options to the > ! postmaster, unless overridden > ! by the option. > ! > ! > ! > ! > ! > ! postmaster.opts > ! > ! > ! If this file exists in the data directory, > ! pg_ctl (in mode) > ! will pass the contents of the file as options to the > ! postmaster, unless overridden > ! by the option. The contents of this file > ! are also displayed in mode. > ! > ! > ! > ! > ! > ! postgresql.conf > ! > ! > ! This file, located in the data directory, is parsed to > ! find the proper port to send to the > ! psql when the > ! is given in mode. > ! > ! > ! > ! > ! > > > > *************** > *** 268,274 **** > > Waiting for complete start is not a well-defined operation and may > fail if access control is set up so that a local client cannot > ! connect without manual interaction. It should be avoided. > > > > --- 332,338 ---- > > Waiting for complete start is not a well-defined operation and may > fail if access control is set up so that a local client cannot > ! connect without manual interaction (e.g. password authentication). > > > > > > > > -----BEGIN PGP SIGNATURE----- > Comment: http://www.turnstep.com/pgp.html > > iD8DBQE+V0ZkvJuQZxSWSsgRAjA+AJ9eFCNSb3Kr4v8UxzRa+/nKSTg87wCeOtzz > oZlhuzlz19ctvswFMmoXPAo= > =HQEB > -----END PGP SIGNATURE----- > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > [ Decrypting message... End of raw data. ] -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Re: pg_ctl -w port detection with docs
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches I will try to apply it within the next 48 hours. --------------------------------------------------------------------------- Greg Sabino Mullane wrote: [ There is text before PGP section. ] > [ PGP not available, raw data follows ] > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > NotDashEscaped: You need GnuPG to verify this message > > > (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 > PGP Key: 0x14964AC8 200302230759 > > Index: pg_ctl.sh > =================================================================== > RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/pg_ctl.sh,v > retrieving revision 1.31 > diff -c -r1.31 pg_ctl.sh > *** pg_ctl.sh 2003/02/14 22:18:25 1.31 > --- pg_ctl.sh 2003/02/22 14:47:09 > *************** > *** 60,65 **** > --- 60,66 ---- > # Placed here during build > bindir='@bindir@' > VERSION='@VERSION@' > + DEF_PGPORT='@DEF_PGPORT@' > > # protect the log file > umask 077 > *************** > *** 240,245 **** > --- 241,247 ---- > 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,367 **** > 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. > --- 358,363 ---- > *************** > *** 369,380 **** > # 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 > # this time), psql will fail (to find libpq). > ! # 7) If psql is misconfigured, this may fail. > ! if "$PGPATH/psql" -l >/dev/null 2>&1 > then > break; > else > --- 365,390 ---- > # may fail. > # 4) When no Unix domain sockets are available, the connection will > # fail. (Using TCP/IP by default ain't better.) > ! # 5) If the dynamic loader is not set up correctly (for this user/at > # this time), psql will fail (to find libpq). > ! # 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 > Index: Makefile > =================================================================== > RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/Makefile,v > retrieving revision 1.10 > diff -c -r1.10 Makefile > *** Makefile 2000/11/25 17:17:30 1.10 > --- Makefile 2003/02/22 14:47:40 > *************** > *** 17,22 **** > --- 17,23 ---- > 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 $@ > > > > > Index: pg_ctl-ref.sgml > =================================================================== > RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/pg_ctl-ref.sgml,v > retrieving revision 1.18 > diff -c -r1.18 pg_ctl-ref.sgml > *** pg_ctl-ref.sgml 2003/01/19 00:13:30 1.18 > --- pg_ctl-ref.sgml 2003/02/23 12:56:04 > *************** > *** 73,94 **** > PostgreSQL backend server, or displaying > the status of a running postmaster. Although the postmaster can be > started manually, pg_ctl encapsulates > ! tasks such as redirecting log output, properly detaching from the > ! terminal and process group, and it provides convenient options for > controlled shutdown. > > > > In mode, a new postmaster is launched. The > ! server is started in the background, the standard input attached to > /dev/null. The standard output and standard > ! error are either appended to a log file, if the > ! option is used, or are redirected to > ! pg_ctl's standard output (not standard > ! error). If no log file is chosen, the standard output of > ! pg_ctl should be redirected to a file or > ! piped to another process, for example a log rotating program, > ! otherwise the postmaster will write its output the the controlling > terminal (from the background) and will not leave the shell's > process group. > > --- 73,93 ---- > PostgreSQL backend server, or displaying > the status of a running postmaster. Although the postmaster can be > started manually, pg_ctl encapsulates > ! tasks such as redirecting log output and properly detaching from the > ! terminal and process group. It also provides convenient options for > controlled shutdown. > > > > In mode, a new postmaster is launched. The > ! server is started in the background, and standard input is attached to > /dev/null. The standard output and standard > ! error are either appended to a log file (if the > ! option is used), or redirected to pg_ctl's > ! standard output (not standard error). If no log file is chosen, the > ! standard output of pg_ctl should be redirected > ! to a file or piped to another process, for example a log rotating program, > ! otherwise the postmaster will write its output to the controlling > terminal (from the background) and will not leave the shell's > process group. > > *************** > *** 102,109 **** > not wait for clients to disconnect. All active transactions are > rolled back and clients are forcibly disconnected, then the > database is shut down. Immediate mode will abort > ! all server processes without clean shutdown. This will lead to a recovery > ! run on restart. > > > > --- 101,108 ---- > not wait for clients to disconnect. All active transactions are > rolled back and clients are forcibly disconnected, then the > database is shut down. Immediate mode will abort > ! all server processes without a clean shutdown. This will lead to > ! a recovery run on restart. > > > > *************** > *** 121,129 **** > > > > ! mode checks whether a postmaster is running > ! and if so displays the PID and the command line > ! options that were used to invoke it. > > > > --- 120,128 ---- > > > > ! mode checks whether a postmaster is running. > ! If it is, the PID and the command line > ! options that were used to invoke it are displayed. > > > > *************** > *** 188,194 **** > > Specifies the location of the postmaster > executable. By default the postmaster is taken from the same > ! directory as pg_ctl</>, or failing that, the hard-wired > installation directory. It is not necessary to use this > option unless you are doing something unusual and get errors > that the postmaster was not found. > --- 187,193 ---- > > Specifies the location of the postmaster > executable. By default the postmaster is taken from the same > ! directory as pg_ctl, or failing that, the hard-wired > installation directory. It is not necessary to use this > option unless you are doing something unusual and get errors > that the postmaster was not found. > *************** > *** 210,216 **** > > > Wait for the start or shutdown to complete. Times out after > ! 60 seconds. This is the default for shutdowns. > > > > --- 209,224 ---- > > > Wait for the start or shutdown to complete. Times out after > ! 60 seconds. This is the default for shutdowns. A successful > ! shutdown is indicated by removal of the PID > ! file. For starting up, a successful psql -l > ! indicates success. pg_ctl will attempt to > ! use the proper port for psql. If the environment variable > ! PGPORT exists, that is used. Otherwise, it will see if a port > ! has been set in the postgresql.conf file. > ! If neither of those is used, it will use the default port that > ! PostgreSQL was compiled with > ! (5432 by default). > > > > *************** > *** 238,247 **** > > > > ! Default data direction location > > > > > > > --- 246,265 ---- > > > > ! Default data directory location. > > > > + > + > + PGPORT > + > + > + > + Default port for (used by the -w option). > + > + > + > > > > *************** > *** 253,264 **** > > Files > > ! > ! If the file postmaster.opts.default exists in > ! the data directory, the contents of the file will be passed as > ! options to the postmaster, unless > ! overridden by the option. > ! > > > > --- 271,328 ---- > > Files > > ! > ! > ! postmaster.pid > ! > ! > ! The existence of this file in the data directory is used to help > ! pg_ctl determine if the server is > ! currently running or not. > ! > ! > ! > ! > ! > ! postmaster.opts.default > ! > ! > ! If this file exists in the data directory, > ! pg_ctl (in mode) > ! will pass the contents of the file as options to the > ! postmaster, unless overridden > ! by the option. > ! > ! > ! > ! > ! > ! postmaster.opts > ! > ! > ! If this file exists in the data directory, > ! pg_ctl (in mode) > ! will pass the contents of the file as options to the > ! postmaster, unless overridden > ! by the option. The contents of this file > ! are also displayed in mode. > ! > ! > ! > ! > ! > ! postgresql.conf > ! > ! > ! This file, located in the data directory, is parsed to > ! find the proper port to send to the > ! psql when the > ! is given in mode. > ! > ! > ! > ! > ! > > > > *************** > *** 268,274 **** > > Waiting for complete start is not a well-defined operation and may > fail if access control is set up so that a local client cannot > ! connect without manual interaction. It should be avoided. > > > > --- 332,338 ---- > > Waiting for complete start is not a well-defined operation and may > fail if access control is set up so that a local client cannot > ! connect without manual interaction (e.g. password authentication). > > > > > > > > -----BEGIN PGP SIGNATURE----- > Comment: http://www.turnstep.com/pgp.html > > iD8DBQE+V0ZkvJuQZxSWSsgRAjA+AJ9eFCNSb3Kr4v8UxzRa+/nKSTg87wCeOtzz > oZlhuzlz19ctvswFMmoXPAo= > =HQEB > -----END PGP SIGNATURE----- > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > [ Decrypting message... End of raw data. ] -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Re: pg_ctl -w port detection with docs
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Patch applied. Thanks. --------------------------------------------------------------------------- Greg Sabino Mullane wrote: [ There is text before PGP section. ] > [ PGP not available, raw data follows ] > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > NotDashEscaped: You need GnuPG to verify this message > > > (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 > PGP Key: 0x14964AC8 200302230759 > > Index: pg_ctl.sh > =================================================================== > RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/pg_ctl.sh,v > retrieving revision 1.31 > diff -c -r1.31 pg_ctl.sh > *** pg_ctl.sh 2003/02/14 22:18:25 1.31 > --- pg_ctl.sh 2003/02/22 14:47:09 > *************** > *** 60,65 **** > --- 60,66 ---- > # Placed here during build > bindir='@bindir@' > VERSION='@VERSION@' > + DEF_PGPORT='@DEF_PGPORT@' > > # protect the log file > umask 077 > *************** > *** 240,245 **** > --- 241,247 ---- > 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,367 **** > 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. > --- 358,363 ---- > *************** > *** 369,380 **** > # 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 > # this time), psql will fail (to find libpq). > ! # 7) If psql is misconfigured, this may fail. > ! if "$PGPATH/psql" -l >/dev/null 2>&1 > then > break; > else > --- 365,390 ---- > # may fail. > # 4) When no Unix domain sockets are available, the connection will > # fail. (Using TCP/IP by default ain't better.) > ! # 5) If the dynamic loader is not set up correctly (for this user/at > # this time), psql will fail (to find libpq). > ! # 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 > Index: Makefile > =================================================================== > RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/Makefile,v > retrieving revision 1.10 > diff -c -r1.10 Makefile > *** Makefile 2000/11/25 17:17:30 1.10 > --- Makefile 2003/02/22 14:47:40 > *************** > *** 17,22 **** > --- 17,23 ---- > 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 $@ > > > > > Index: pg_ctl-ref.sgml > =================================================================== > RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/pg_ctl-ref.sgml,v > retrieving revision 1.18 > diff -c -r1.18 pg_ctl-ref.sgml > *** pg_ctl-ref.sgml 2003/01/19 00:13:30 1.18 > --- pg_ctl-ref.sgml 2003/02/23 12:56:04 > *************** > *** 73,94 **** > PostgreSQL backend server, or displaying > the status of a running postmaster. Although the postmaster can be > started manually, pg_ctl encapsulates > ! tasks such as redirecting log output, properly detaching from the > ! terminal and process group, and it provides convenient options for > controlled shutdown. > > > > In mode, a new postmaster is launched. The > ! server is started in the background, the standard input attached to > /dev/null. The standard output and standard > ! error are either appended to a log file, if the > ! option is used, or are redirected to > ! pg_ctl's standard output (not standard > ! error). If no log file is chosen, the standard output of > ! pg_ctl should be redirected to a file or > ! piped to another process, for example a log rotating program, > ! otherwise the postmaster will write its output the the controlling > terminal (from the background) and will not leave the shell's > process group. > > --- 73,93 ---- > PostgreSQL backend server, or displaying > the status of a running postmaster. Although the postmaster can be > started manually, pg_ctl encapsulates > ! tasks such as redirecting log output and properly detaching from the > ! terminal and process group. It also provides convenient options for > controlled shutdown. > > > > In mode, a new postmaster is launched. The > ! server is started in the background, and standard input is attached to > /dev/null. The standard output and standard > ! error are either appended to a log file (if the > ! option is used), or redirected to pg_ctl's > ! standard output (not standard error). If no log file is chosen, the > ! standard output of pg_ctl should be redirected > ! to a file or piped to another process, for example a log rotating program, > ! otherwise the postmaster will write its output to the controlling > terminal (from the background) and will not leave the shell's > process group. > > *************** > *** 102,109 **** > not wait for clients to disconnect. All active transactions are > rolled back and clients are forcibly disconnected, then the > database is shut down. Immediate mode will abort > ! all server processes without clean shutdown. This will lead to a recovery > ! run on restart. > > > > --- 101,108 ---- > not wait for clients to disconnect. All active transactions are > rolled back and clients are forcibly disconnected, then the > database is shut down. Immediate mode will abort > ! all server processes without a clean shutdown. This will lead to > ! a recovery run on restart. > > > > *************** > *** 121,129 **** > > > > ! mode checks whether a postmaster is running > ! and if so displays the PID and the command line > ! options that were used to invoke it. > > > > --- 120,128 ---- > > > > ! mode checks whether a postmaster is running. > ! If it is, the PID and the command line > ! options that were used to invoke it are displayed. > > > > *************** > *** 188,194 **** > > Specifies the location of the postmaster > executable. By default the postmaster is taken from the same > ! directory as pg_ctl</>, or failing that, the hard-wired > installation directory. It is not necessary to use this > option unless you are doing something unusual and get errors > that the postmaster was not found. > --- 187,193 ---- > > Specifies the location of the postmaster > executable. By default the postmaster is taken from the same > ! directory as pg_ctl, or failing that, the hard-wired > installation directory. It is not necessary to use this > option unless you are doing something unusual and get errors > that the postmaster was not found. > *************** > *** 210,216 **** > > > Wait for the start or shutdown to complete. Times out after > ! 60 seconds. This is the default for shutdowns. > > > > --- 209,224 ---- > > > Wait for the start or shutdown to complete. Times out after > ! 60 seconds. This is the default for shutdowns. A successful > ! shutdown is indicated by removal of the PID > ! file. For starting up, a successful psql -l > ! indicates success. pg_ctl will attempt to > ! use the proper port for psql. If the environment variable > ! PGPORT exists, that is used. Otherwise, it will see if a port > ! has been set in the postgresql.conf file. > ! If neither of those is used, it will use the default port that > ! PostgreSQL was compiled with > ! (5432 by default). > > > > *************** > *** 238,247 **** > > > > ! Default data direction location > > > > > > > --- 246,265 ---- > > > > ! Default data directory location. > > > > + > + > + PGPORT > + > + > + > + Default port for (used by the -w option). > + > + > + > > > > *************** > *** 253,264 **** > > Files > > ! > ! If the file postmaster.opts.default exists in > ! the data directory, the contents of the file will be passed as > ! options to the postmaster, unless > ! overridden by the option. > ! > > > > --- 271,328 ---- > > Files > > ! > ! > ! postmaster.pid > ! > ! > ! The existence of this file in the data directory is used to help > ! pg_ctl determine if the server is > ! currently running or not. > ! > ! > ! > ! > ! > ! postmaster.opts.default > ! > ! > ! If this file exists in the data directory, > ! pg_ctl (in mode) > ! will pass the contents of the file as options to the > ! postmaster, unless overridden > ! by the option. > ! > ! > ! > ! > ! > ! postmaster.opts > ! > ! > ! If this file exists in the data directory, > ! pg_ctl (in mode) > ! will pass the contents of the file as options to the > ! postmaster, unless overridden > ! by the option. The contents of this file > ! are also displayed in mode. > ! > ! > ! > ! > ! > ! postgresql.conf > ! > ! > ! This file, located in the data directory, is parsed to > ! find the proper port to send to the > ! psql when the > ! is given in mode. > ! > ! > ! > ! > ! > > > > *************** > *** 268,274 **** > > Waiting for complete start is not a well-defined operation and may > fail if access control is set up so that a local client cannot > ! connect without manual interaction. It should be avoided. > > > > --- 332,338 ---- > > Waiting for complete start is not a well-defined operation and may > fail if access control is set up so that a local client cannot > ! connect without manual interaction (e.g. password authentication). > > > > > > > > -----BEGIN PGP SIGNATURE----- > Comment: http://www.turnstep.com/pgp.html > > iD8DBQE+V0ZkvJuQZxSWSsgRAjA+AJ9eFCNSb3Kr4v8UxzRa+/nKSTg87wCeOtzz > oZlhuzlz19ctvswFMmoXPAo= > =HQEB > -----END PGP SIGNATURE----- > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > [ Decrypting message... End of raw data. ] -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073