Update pg_ctl ref page, help output, messages. Some repair to work better

with current postmaster.
This commit is contained in:
Peter Eisentraut 2000-11-25 17:17:30 +00:00
parent f4710020d6
commit c25b4dbf03
3 changed files with 235 additions and 271 deletions

View File

@ -1,42 +1,76 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_ctl-ref.sgml,v 1.3 2000/10/12 22:13:21 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_ctl-ref.sgml,v 1.4 2000/11/25 17:17:30 petere Exp $
Postgres documentation Postgres documentation
--> -->
<refentry id="app-pg-ctl"> <refentry id="app-pg-ctl">
<docinfo>
<date>2000-11-25</date>
</docinfo>
<refmeta> <refmeta>
<refentrytitle id="app-pg-ctl-title"> <refentrytitle id="app-pg-ctl-title"><application>pg_ctl</application></refentrytitle>
<application>pg_ctl</application> <manvolnum>1</manvolnum>
</refentrytitle>
<refmiscinfo>Application</refmiscinfo> <refmiscinfo>Application</refmiscinfo>
</refmeta> </refmeta>
<refnamediv> <refnamediv>
<refname> <refname>pg_ctl</refname>
<application>pg_ctl</application> <refpurpose>Starts, stops, or restarts postmaster</refpurpose>
</refname>
<refpurpose>
Starts, stops, and restarts postmaster
</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<refsynopsisdivinfo> <cmdsynopsis>
<date>2000-04-05</date> <command>pg_ctl</command>
</refsynopsisdivinfo> <arg choice="plain">start</arg>
<arg>-w</arg>
<arg>-D <replaceable>datadir</replaceable></arg>
<arg>-p <replaceable>path</replaceable></arg>
<arg>-o <replaceable>options</replaceable></arg>
<sbr>
<command>pg_ctl</command>
<arg choice="plain">stop</arg>
<arg>-w</arg>
<arg>-D <replaceable>datadir</replaceable></arg>
<arg>-m
<group choice="plain">
<arg>s[mart]</arg>
<arg>f[ast]</arg>
<arg>i[mmediate]</arg>
</group>
</arg>
<sbr>
<command>pg_ctl</command>
<arg choice="plain">restart</arg>
<arg>-w</arg>
<arg>-D <replaceable>datadir</replaceable></arg>
<arg>-m
<group choice="plain">
<arg>s[mart]</arg>
<arg>f[ast]</arg>
<arg>i[mmediate]</arg>
</group>
</arg>
<arg>-o <replaceable>options</replaceable></arg>
<sbr>
<command>pg_ctl</command>
<arg choice="plain">status</arg>
<arg>-D <replaceable>datadir</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<synopsis>
pg_ctl [-w] [-D <replaceable class="parameter">datadir</replaceable>][-p <replaceable class="parameter">path</replaceable>] [-o "<replaceable class="parameter">options</replaceable>"] start
pg_ctl [-w] [-D <replaceable class="parameter">datadir</replaceable>] [-m [s[mart]|f[ast]|i[mmediate]]] stop
pg_ctl [-w] [-D <replaceable class="parameter">datadir</replaceable>] [-m [s[mart]|f[ast]|i[mmediate]]
[-o "<replaceable class="parameter">options</replaceable>"] restart
pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
</synopsis>
<refsect2 id="R2-APP-PGCTL-1"> <refsect1 id="app-pg-ctl-description">
<title> <title>Description</title>
Inputs <para>
</title> <application>pg_ctl</application> is a utility for starting,
stopping, or restarting the <xref linkend="app-postmaster"
endterm="app-postmaster-title">, or displaying the status of a
running postmaster.
</para>
<refsect2 id="app-pg-ctl-options">
<title>Options</title>
<para> <para>
<variablelist> <variablelist>
@ -44,8 +78,9 @@ pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
<term>-w</term> <term>-w</term>
<listitem> <listitem>
<para> <para>
Wait for the database server to come up, by Wait for the database server to come up, by watching for
watching for creation of the pid file (PGDATA/postmaster.pid). creation of the pid file
(<filename><replaceable>PGDATA</replaceable>/postmaster.pid</filename>).
Times out after 60 seconds. Times out after 60 seconds.
</para> </para>
</listitem> </listitem>
@ -55,7 +90,9 @@ pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
<term>-D <replaceable class="parameter">datadir</replaceable></term> <term>-D <replaceable class="parameter">datadir</replaceable></term>
<listitem> <listitem>
<para> <para>
Specifies the database location for this database installation. Specifies the file system location of the database files. If
this is omitted, the environment variable
<envar>PGDATA</envar> is used.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -64,13 +101,18 @@ pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
<term>-p <replaceable class="parameter">path</replaceable></term> <term>-p <replaceable class="parameter">path</replaceable></term>
<listitem> <listitem>
<para> <para>
Specifies the path to the postmaster image. Specifies the location of the <filename>postmaster</filename>
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.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>-o "<replaceable class="parameter">options</replaceable>"</term> <term>-o <replaceable class="parameter">options</replaceable></term>
<listitem> <listitem>
<para> <para>
Specifies options to be passed directly to Specifies options to be passed directly to
@ -95,8 +137,8 @@ pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
<term>s</term> <term>s</term>
<listitem> <listitem>
<para> <para>
smart mode waits for all Smart mode waits for all the clients to disconnect. This
the clients to logout. This is the default. is the default.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -106,8 +148,8 @@ pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
<term>f</term> <term>f</term>
<listitem> <listitem>
<para> <para>
Fast mode sends SIGTERM to the backends; that means Fast mode does not wait for clients to disconnect. All
active transactions get rolled back. active transactions will be rolled back.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -117,9 +159,8 @@ pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
<term>i</term> <term>i</term>
<listitem> <listitem>
<para> <para>
Immediate mode sends SIGUSR1 Immediate mode will abort without complete shutdown. This
to the backends and lets them abort. In this case, database recovery will lead to a recovery run on restart.
will be necessary on the next start-up.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -150,8 +191,8 @@ pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
<term>restart</term> <term>restart</term>
<listitem> <listitem>
<para> <para>
Restart the <application>postmaster</application>, performing Stop the <application>postmaster</application>, if one is running,
a stop/start sequence. and then start it again.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -168,229 +209,107 @@ pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
</para> </para>
</refsect2> </refsect2>
<refsect2 id="R2-APP-PGCTL-2"> <refsect2>
<refsect2info> <title>Files</title>
<date>1999-11-07</date>
</refsect2info>
<title>
Outputs
</title>
<para>
<variablelist>
<varlistentry>
<term><computeroutput>pg_ctl: postmaster is <replaceable>state</replaceable> (pid: <replaceable>#</replaceable>)</computeroutput></term>
<listitem>
<para>
Postmaster status.
</para>
</listitem>
</varlistentry>
</variablelist>
If there is an error condition, the backend error message will be displayed. <para>
If the file <filename>postmaster.opts.default</filename> exists in
the data directory, the contents of the file will be passed as
options to the <application>postmaster</application>, unless
overridden by the <option>-o</option> option.
</para> </para>
</refsect2> </refsect2>
</refsynopsisdiv>
<refsect1 id="R1-APP-PGCTL-1">
<title>
Description
</title>
<para>
<application>pg_ctl</application> is a utility for starting,
stopping or restarting <application>postmaster</application>.
</para>
</refsect1> </refsect1>
<refsect1 id="R1-APP-PGCTL-2"> <refsect1 id="R1-APP-PGCTL-2">
<title> <title>Usage</title>
Usage
</title>
<refsect2 id="R2-APP-PGCTL-3"> <refsect2 id="R2-APP-PGCTL-3">
<title> <title>Starting the postmaster</title>
Starting postmaster
</title>
<para> <para>
To start up <application>postmaster</application>: To start up <application>postmaster</application>:
<screen>
<programlisting> <prompt>$</prompt> <userinput>pg_ctl start</userinput>
$ pg_ctl start </screen>
</programlisting>
</para> </para>
<para> <para>
If -w is supplied, pg_ctl waits for the database server to come up, by An example of starting the <application>postmaster</application>,
watching for creation of the pid file (PGDATA/postmaster.pid), for up blocking until postmaster comes up is:
to 60 seconds. <screen>
</para> <prompt>$</prompt> <userinput>pg_ctl -w start</userinput>
</screen>
<para>
Parameters to invoke <application>postmaster</application> are
taken from the following sources:
<itemizedlist>
<listitem>
<para>
Path to postmaster: found in the command search path.
</para>
</listitem>
<listitem>
<para>
Database directory: <envar>PGDATA</envar> environment variable.
</para>
</listitem>
<listitem>
<para>
Other parameters:
<filename><envar>PGDATA</envar>/postmaster.opts.default</filename>.
</para>
</listitem>
</itemizedlist>
</para>
<para>
<filename>postmaster.opts.default</filename> contains parameters
for <application>postmaster</application>.
</para>
<para>
Note that <filename>postmaster.opts.default</filename> is
installed by <application>initdb</application> from
<filename>lib/postmaster.opts.default.sample</filename>
under the <productname>Postgres</productname> installation
directory (<filename>lib/postmaster.opts.default.sample</filename>
is copied from
<filename>src/bin/pg_ctl/postmaster.opts.default.sample</filename>
while installing <productname>Postgres</productname>).
</para>
<para>
To override the default parameters you can use <option>-D</option>,
<option>-p</option> and <option>-o</option> options.
</para>
<para>
An example of starting the
<application>postmaster</application>, blocking until
postmaster comes up is:
<programlisting>
$ pg_ctl -w start
</programlisting>
</para>
<para>
To specify the <application>postmaster</application> binary path,
try:
<programlisting>
$ pg_ctl -p /usr/local/pgsql/bin/postmaster start
</programlisting>
</para> </para>
<para> <para>
For a <application>postmaster</application> using port 5433, and For a <application>postmaster</application> using port 5433, and
running without <function>fsync</function>, use: running without <function>fsync</function>, use:
<screen>
<programlisting> <prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" start</userinput>
$ pg_ctl -o "-o -F -p 5433" start </screen>
</programlisting>
</para> </para>
</refsect2> </refsect2>
<refsect2 id="R2-APP-PGCTL-4"> <refsect2 id="R2-APP-PGCTL-4">
<title> <title>Stopping the postmaster</title>
Stopping postmaster
</title>
<para> <para>
<screen>
<programlisting> <prompt>$</prompt> <userinput>pg_ctl stop</userinput>
$ pg_ctl stop </screen>
</programlisting>
stops postmaster. Using the <option>-m</option> switch allows one stops postmaster. Using the <option>-m</option> switch allows one
to control <emphasis>how</emphasis> the backend shuts down. to control <emphasis>how</emphasis> the backend shuts down.
<option>-w</option> <option>-w</option> waits for postmaster to shut down.
waits for postmaster to shut down.
<option>-m</option> specifies the shut down mode.
</para> </para>
</refsect2> </refsect2>
<refsect2 id="R2-APP-PGCTL-5"> <refsect2 id="R2-APP-PGCTL-5">
<title> <title>Restarting the postmaster</title>
Restarting postmaster
</title>
<para> <para>
This is almost equivalent to stopping the This is almost equivalent to stopping the
<application>postmaster</application> then starting it <application>postmaster</application> then starting it again
again except that the parameters used before stopping except that pg_ctl saves and reuses the command line options that
it would be used too. This is done by saving them in were passed to the previously running instance. To restart
$<envar>PGDATA</envar>/postmaster.opts file. <application>postmaster</application> in the simplest form:
<option>-w</option>, <option>-D</option>, <option>-m</option>, <screen>
<option>-fast</option>, <option>-immediate</option> and <prompt>$</prompt> <userinput>pg_ctl restart</userinput>
<option>-o</option> </screen>
can also be used in the restarting mode and they have the same meanings as
described above.
</para>
<para>
To restart <application>postmaster</application> in the simplest
form:
<programlisting>
$ pg_ctl restart
</programlisting>
</para> </para>
<para> <para>
To restart <application>postmaster</application>, To restart <application>postmaster</application>,
waiting for it to shut down and to come up: waiting for it to shut down and to come up:
<screen>
<programlisting> <prompt>$</prompt> <userinput>pg_ctl -w restart</userinput>
$ pg_ctl -w restart </screen>
</programlisting>
</para> </para>
<para> <para>
To restart using port 5433 and disabling fsync after restarting: To restart using port 5433 and disabling fsync after restarting:
<screen>
<programlisting> <prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" restart</userinput>
$ pg_ctl -o "-o -F -p 5433" restart </screen>
</programlisting>
</para> </para>
</refsect2> </refsect2>
<refsect2 id="R2-APP-PGCTL-6"> <refsect2 id="R2-APP-PGCTL-6">
<title> <title>Showing postmaster status</title>
postmaster status
</title>
<para> <para>
To get status information from postmaster: Here is a sample status output from
<application>pg_ctl</application>:
<programlisting> <screen>
$ pg_ctl status <prompt>$</prompt> <userinput>pg_ctl status</userinput>
</programlisting> <computeroutput>
</para>
<para>
Here is a sample output from <application>pg_ctl</application>:
<programlisting>
pg_ctl: postmaster is running (pid: 13718) pg_ctl: postmaster is running (pid: 13718)
options are: Command line was:
/usr/local/src/pgsql/current/bin/postmaster /usr/local/pgsql/bin/postmaster '-D' '/usr/local/pgsql/data' '-p' '5433' '-B' '128'
-p 5433 </computeroutput>
-D /usr/local/src/pgsql/current/data </screen>
-B 64 This is the command line that would be invoked in restart mode.
-b /usr/local/src/pgsql/current/bin/postgres
-N 32
-o '-F'
</programlisting>
</para> </para>
</refsect2> </refsect2>
</refsect1> </refsect1>

View File

@ -4,7 +4,7 @@
# #
# Copyright (c) 1999, PostgreSQL Global Development Group # Copyright (c) 1999, PostgreSQL Global Development Group
# #
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Makefile,v 1.9 2000/09/17 13:02:35 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/pg_ctl/Makefile,v 1.10 2000/11/25 17:17:30 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -15,7 +15,9 @@ include $(top_builddir)/src/Makefile.global
all: pg_ctl all: pg_ctl
pg_ctl: pg_ctl.sh pg_ctl: pg_ctl.sh
cp $< $@ sed -e 's/@VERSION@/$(VERSION)/g' \
-e 's,@bindir@,$(bindir),g' \
$< >$@
chmod a+x $@ chmod a+x $@
install: all installdirs install: all installdirs

View File

@ -8,14 +8,50 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.13 2000/10/24 19:11:15 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.14 2000/11/25 17:17:30 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
CMDNAME=`basename $0` CMDNAME=`basename $0`
help="\
$CMDNAME is a utility to start, stop, restart, and report the status
of a PostgreSQL server.
Usage:
$CMDNAME start [-w] [-D DATADIR] [-p PATH-TO-POSTMASTER] [-o \"OPTIONS\"]
$CMDNAME stop [-w] [-D DATADIR] [-m SHUTDOWN-MODE]
$CMDNAME restart [-w] [-D DATADIR] [-m SHUTDOWN-MODE] [-o \"OPTIONS\"]
$CMDNAME status [-D DATADIR]
Options:
-D DATADIR Location of the database storage area
-m SHUTDOWN-MODE May be 'smart', 'fast', or 'immediate'
-o OPTIONS Command line options to pass to the postmaster
(PostgreSQL server executable)
-p PATH-TO-POSTMASTER Normally not necessary
-w Wait until operation completes
If the -D option is omitted, the environment variable PGDATA is used.
Shutdown modes are:
smart Quit after all clients have disconnected
fast Quit directly, with proper shutdown
immediate Quit without complete shutdown; will lead
to recovery run on restart
Report bugs to <pgsql-bugs@postgresql.org>."
advice="\
Try '$CMDNAME --help' for more information."
# Placed here during build
bindir='@bindir@'
VERSION='@VERSION@'
# Check for echo -n vs echo \c # Check for echo -n vs echo \c
ECHO=echo
if echo '\c' | grep -s c >/dev/null 2>&1 if echo '\c' | grep -s c >/dev/null 2>&1
then then
ECHO_N="echo -n" ECHO_N="echo -n"
@ -28,38 +64,35 @@ fi
# #
# Find out where we're located # Find out where we're located
# #
if $ECHO "$0" | grep '/' > /dev/null 2>&1 if echo "$0" | grep '/' > /dev/null 2>&1
then then
# explicit dir name given # explicit dir name given
PGPATH=`$ECHO $0 | sed 's,/[^/]*$,,'` # (dirname command is not portable) self_path=`echo $0 | sed 's,/[^/]*$,,'` # (dirname command is not portable)
else else
# look for it in PATH ('which' command is not portable) # look for it in PATH ('which' command is not portable)
for dir in `$ECHO "$PATH" | sed 's/:/ /g'` for dir in `echo "$PATH" | sed 's/:/ /g'`
do do
# empty entry in path means current dir # empty entry in path means current dir
[ -z "$dir" ] && dir='.' [ -z "$dir" ] && dir='.'
if [ -f "$dir/$CMDNAME" ] if [ -f "$dir/$CMDNAME" ]
then then
PGPATH="$dir" self_path="$dir"
break break
fi fi
done done
fi fi
# Check if needed programs actually exist in path # Check if needed programs actually exist in path
for prog in postmaster psql if [ -x "$self_path/postmaster" ] && [ -x "$self_path/psql" ]; then
do PGPATH=$self_path
if [ ! -x "$PGPATH/$prog" ] elif [ -x "$bindir/postmaster" ] && [ -x "$bindir/psql" ]; then
then PGPATH=$bindir
$ECHO "The program $prog needed by $CMDNAME could not be found. It was" else
$ECHO "expected at:" echo "The programs 'postmaster' and 'psql' are needed by $CMDNAME but" 1>&2
$ECHO " $PGPATH/$prog" echo "were not found in the directory '$bindir'." 1>&2
$ECHO "If this is not the correct directory, please start $CMDNAME" echo "Check your installation." 1>&2
$ECHO "with a full search path. Otherwise make sure that the program" exit 1
$ECHO "was installed successfully." fi
exit 1
fi
done
po_path=$PGPATH/postmaster po_path=$PGPATH/postmaster
@ -69,14 +102,17 @@ sig="-TERM"
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case $1 in case $1 in
-h|--help) -h|--help|-\?)
usage=1 echo "$help"
break exit 0
;; ;;
-V|--version)
echo "pg_ctl (PostgreSQL) $VERSION"
exit 0
;;
-D) -D)
shift shift
PGDATA="$1" PGDATA="$1"
export PGDATA
;; ;;
-p) -p)
shift shift
@ -94,8 +130,9 @@ do
sig="-QUIT" sig="-QUIT"
;; ;;
*) *)
$ECHO "$CMDNAME: Wrong shutdown mode $sigopt" echo "$CMDNAME: wrong shutdown mode: $1" 1>&2
usage=1 echo "$advice" 1>&2
exit 1
;; ;;
esac esac
;; ;;
@ -106,6 +143,11 @@ do
shift shift
POSTOPTS="$1" POSTOPTS="$1"
;; ;;
-*)
echo "$CMDNAME: invalid option: $1" 1>&2
echo "$advice" 1>&2
exit 1
;;
start) start)
op="start" op="start"
;; ;;
@ -119,23 +161,23 @@ do
op="status" op="status"
;; ;;
*) *)
usage=1 echo "$CMDNAME: invalid operation mode: $1" 1>&2
break echo "$advice" 1>&2
exit 1
;; ;;
esac esac
shift shift
done done
if [ "$usage" = 1 -o "$op" = "" ];then if [ x"$op" = x"" ];then
$ECHO "Usage: $CMDNAME [-w][-D database_dir][-p path_to_postmaster][-o \"postmaster_opts\"] start" echo "$CMDNAME: no operation mode specified" 1>&2
$ECHO " $CMDNAME [-w][-D database_dir][-m s[mart]|f[ast]|i[mmediate]] stop" echo "$advice" 1>&2
$ECHO " $CMDNAME [-w][-D database_dir][-m s[mart]|f[ast]|i[mmediate]][-o \"postmaster_opts\"] restart"
$ECHO " $CMDNAME [-D database_dir] status"
exit 1 exit 1
fi fi
if [ -z "$PGDATA" ];then if [ -z "$PGDATA" ];then
$ECHO "$CMDNAME: No database directory or environment variable \$PGDATA is specified" echo "$CMDNAME: no database directory or environment variable \$PGDATA is specified" 1>&2
echo "$advice" 1>&2
exit 1 exit 1
fi fi
@ -148,15 +190,15 @@ if [ $op = "status" ];then
PID=`cat $PIDFILE` PID=`cat $PIDFILE`
if [ $PID -lt 0 ];then if [ $PID -lt 0 ];then
PID=`expr 0 - $PID` PID=`expr 0 - $PID`
$ECHO "$CMDNAME: postgres is running (pid: $PID)" echo "$CMDNAME: postgres is running (pid: $PID)"
else else
$ECHO "$CMDNAME: postmaster is running (pid: $PID)" echo "$CMDNAME: postmaster is running (pid: $PID)"
$ECHO "options are:" echo "Command line was:"
$ECHO "`cat $POSTOPTSFILE`" echo "`cat $POSTOPTSFILE`"
fi fi
exit 0 exit 0
else else
$ECHO "$CMDNAME: postmaster or postgres is not running" echo "$CMDNAME: postmaster or postgres is not running"
exit 1 exit 1
fi fi
fi fi
@ -166,8 +208,8 @@ if [ $op = "stop" -o $op = "restart" ];then
PID=`cat $PIDFILE` PID=`cat $PIDFILE`
if [ $PID -lt 0 ];then if [ $PID -lt 0 ];then
PID=`expr 0 - $PID` PID=`expr 0 - $PID`
$ECHO "$CMDNAME: Cannot restart postmaster. postgres is running (pid: $PID)" echo "$CMDNAME: Cannot restart postmaster. postgres is running (pid: $PID)"
$ECHO "Please terminate postgres and try again" echo "Please terminate postgres and try again"
exit 1 exit 1
fi fi
@ -176,7 +218,7 @@ if [ $op = "stop" -o $op = "restart" ];then
# wait for postmaster shutting down # wait for postmaster shutting down
if [ "$wait" = 1 -o $op = "restart" ];then if [ "$wait" = 1 -o $op = "restart" ];then
cnt=0 cnt=0
$ECHO_N "Waiting for postmaster shutting down.."$ECHO_C $ECHO_N "Waiting for postmaster to shut down.."$ECHO_C
while : while :
do do
@ -184,7 +226,7 @@ if [ $op = "stop" -o $op = "restart" ];then
$ECHO_N "."$ECHO_C $ECHO_N "."$ECHO_C
cnt=`expr $cnt + 1` cnt=`expr $cnt + 1`
if [ $cnt -gt 60 ];then if [ $cnt -gt 60 ];then
$ECHO "$CMDNAME: postmaster does not shut down" echo "$CMDNAME: postmaster does not shut down"
exit 1 exit 1
fi fi
else else
@ -192,16 +234,16 @@ if [ $op = "stop" -o $op = "restart" ];then
fi fi
sleep 1 sleep 1
done done
$ECHO "done." echo "done"
fi fi
$ECHO "postmaster successfully shut down." echo "postmaster successfully shut down"
else else
$ECHO "$CMDNAME: Can't find $PIDFILE." echo "$CMDNAME: cannot find $PIDFILE"
$ECHO "Is postmaster running?" echo "Is postmaster running?"
if [ $op = "restart" ];then if [ $op = "restart" ];then
$ECHO "Anyway, I'm going to start up postmaster..." echo "starting postmaster anyway..."
else else
exit 1 exit 1
fi fi
@ -210,7 +252,7 @@ fi
if [ $op = "start" -o $op = "restart" ];then if [ $op = "start" -o $op = "restart" ];then
if [ -f $PIDFILE ];then if [ -f $PIDFILE ];then
$ECHO "$CMDNAME: It seems another postmaster is running. Try to start postmaster anyway." echo "$CMDNAME: It seems another postmaster is running. Trying to start postmaster anyway."
pid=`cat $PIDFILE` pid=`cat $PIDFILE`
fi fi
@ -219,21 +261,22 @@ if [ $op = "start" -o $op = "restart" ];then
if [ $op = "start" ];then if [ $op = "start" ];then
# if we are in start mode, then look for postmaster.opts.default # if we are in start mode, then look for postmaster.opts.default
if [ -f $DEFPOSTOPTS ];then if [ -f $DEFPOSTOPTS ];then
eval "$po_path `cat $DEFPOSTOPTS`" & $po_path -D $PGDATA `cat $DEFPOSTOPTS` &
else else
$po_path & $po_path -D $PGDATA &
fi fi
else else
# if we are in restart mode, then look postmaster.opts # if we are in restart mode, then look postmaster.opts
eval `cat $POSTOPTSFILE` & `cat $POSTOPTSFILE` &
fi fi
else else
eval "$po_path $POSTOPTS " & # -o given
$po_path -D $PGDATA $POSTOPTS &
fi fi
if [ -f $PIDFILE ];then if [ -f $PIDFILE ];then
if [ "`cat $PIDFILE`" = "$pid" ];then if [ "`cat $PIDFILE`" = "$pid" ];then
$ECHO "$CMDNAME: Cannot start postmaster. Is another postmaster is running?" echo "$CMDNAME: Cannot start postmaster. Is another postmaster is running?"
exit 1 exit 1
fi fi
fi fi
@ -241,7 +284,7 @@ if [ $op = "start" -o $op = "restart" ];then
# wait for postmaster starting up # wait for postmaster starting up
if [ "$wait" = 1 ];then if [ "$wait" = 1 ];then
cnt=0 cnt=0
$ECHO_N "Waiting for postmaster starting up.."$ECHO_C $ECHO_N "Waiting for postmaster to start up.."$ECHO_C
while : while :
do do
if psql -l >/dev/null 2>&1 if psql -l >/dev/null 2>&1
@ -251,16 +294,16 @@ if [ $op = "start" -o $op = "restart" ];then
$ECHO_N "."$ECHO_C $ECHO_N "."$ECHO_C
cnt=`expr $cnt + 1` cnt=`expr $cnt + 1`
if [ $cnt -gt 60 ];then if [ $cnt -gt 60 ];then
$ECHO "$CMDNAME: postmaster does not start up" echo "$CMDNAME: postmaster does not start up"
exit 1 exit 1
fi fi
sleep 1 sleep 1
fi fi
done done
$ECHO "done." echo "done"
fi fi
$ECHO "postmaster successfully started up." echo "postmaster successfully started up"
fi fi
exit 0 exit 0