From 196700c372d6ba9d13f1a38cf6b9a4cef3f0f013 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 21 Sep 2001 21:10:56 +0000 Subject: [PATCH] Add 'reload' option to pg_ctl to send SIGHUP to the postmaster. --- doc/src/sgml/client-auth.sgml | 9 +++++---- doc/src/sgml/ref/pg_ctl-ref.sgml | 22 +++++++++++++++++----- src/bin/pg_ctl/pg_ctl.sh | 27 ++++++++++++++++++++------- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml index 33dba495df..79d74a83a0 100644 --- a/doc/src/sgml/client-auth.sgml +++ b/doc/src/sgml/client-auth.sgml @@ -1,4 +1,4 @@ - + Client Authentication @@ -333,9 +333,10 @@ hostssl database IP-address The pg_hba.conf file is loaded only on startup - and when the postmaster receives a SIGHUP signal. If - you edit the file on an active system, you will need to issue a - SIGHUP to the postmaster using kill + and when the postmaster receives a + SIGHUP signal. If you edit the file on an + active system, you will need to signal the postmaster + (using pg_ctl reload or kill -HUP) to make it re-read the file. diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml index 84022f9f69..668dd861ca 100644 --- a/doc/src/sgml/ref/pg_ctl-ref.sgml +++ b/doc/src/sgml/ref/pg_ctl-ref.sgml @@ -1,5 +1,5 @@ @@ -58,6 +58,11 @@ Postgres documentation -o options pg_ctl + reload + -s + -D datadir + + pg_ctl status -D datadir @@ -73,7 +78,7 @@ Postgres documentation the status of a running postmaster. Although the postmaster can be started manually, pg_ctl encapulates tasks such as redirecting log output, properly detaching from the - terminal and process group, and additionally provides an option for + terminal and process group, and it provides convenient options for controlled shut down. @@ -93,7 +98,7 @@ Postgres documentation - In mode, the postmaster that is running on + In mode, the postmaster that is running in the specified data directory is shut down. Three different shutdown methods can be selected with the option: Smart mode waits for all the clients to @@ -101,7 +106,6 @@ Postgres documentation not wait for clients to disconnect. All active transactions will be rolled back. Immediate mode will abort without complete shutdown. This will lead to a recovery run on restart. - By the default, stop mode waits for the shutdown to complete. @@ -110,6 +114,14 @@ Postgres documentation options. + + mode simply sends the postmaster a SIGHUP signal, + causing it to reread its configuration files + (postgresql.conf, pg_hba.conf, + etc). This allows changing of configuration-file options that do not + require a complete restart to take effect. + + mode checks whether a postmaster is running and if so displays the PID and the command line @@ -188,7 +200,7 @@ Postgres documentation -w - Wait for the start or stutdown to complete. Times out after + Wait for the start or shutdown to complete. Times out after 60 seconds. This is the default for shutdowns. diff --git a/src/bin/pg_ctl/pg_ctl.sh b/src/bin/pg_ctl/pg_ctl.sh index 997e34f6dd..9bd6fc05cc 100755 --- a/src/bin/pg_ctl/pg_ctl.sh +++ b/src/bin/pg_ctl/pg_ctl.sh @@ -2,26 +2,27 @@ #------------------------------------------------------------------------- # # pg_ctl.sh-- -# Start/Stop/Restart/Report status of postmaster +# Start/Stop/Restart/HUP/Report status of postmaster # # Copyright (c) 2001 PostgreSQL Global Development Group # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.23 2001/07/11 19:36:41 momjian Exp $ +# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.24 2001/09/21 21:10:56 tgl Exp $ # #------------------------------------------------------------------------- CMDNAME=`basename $0` help="\ -$CMDNAME is a utility to start, stop, restart, and report the status -of a PostgreSQL server. +$CMDNAME is a utility to start, stop, restart, reload configuration files, +or report the status of a PostgreSQL server. Usage: $CMDNAME start [-w] [-D DATADIR] [-s] [-l FILENAME] [-o \"OPTIONS\"] $CMDNAME stop [-W] [-D DATADIR] [-s] [-m SHUTDOWN-MODE] $CMDNAME restart [-w] [-D DATADIR] [-s] [-m SHUTDOWN-MODE] [-o \"OPTIONS\"] + $CMDNAME reload [-D DATADIR] [-s] $CMDNAME status [-D DATADIR] Common options: @@ -174,6 +175,9 @@ do restart) op="restart" ;; + reload) + op="reload" + ;; status) op="status" ;; @@ -224,6 +228,10 @@ case "$shutdown_mode" in ;; esac +if [ "$op" = "reload" ];then + sig="-HUP" + wait=no +fi DEFPOSTOPTS=$PGDATA/postmaster.opts.default POSTOPTSFILE=$PGDATA/postmaster.opts @@ -247,7 +255,7 @@ if [ "$op" = "status" ];then fi fi -if [ "$op" = "stop" -o "$op" = "restart" ];then +if [ "$op" = "stop" -o "$op" = "restart" -o "$op" = "reload" ];then if [ -f $PIDFILE ];then PID=`sed -n 1p $PIDFILE` if [ $PID -lt 0 ];then @@ -281,7 +289,12 @@ if [ "$op" = "stop" -o "$op" = "restart" ];then done $silence_echo echo "done" fi - $silence_echo echo "postmaster successfully shut down" + + if [ "$op" = "reload" ];then + $silence_echo echo "postmaster successfully signaled" + else + $silence_echo echo "postmaster successfully shut down" + fi else # ! -f $PIDFILE echo "$CMDNAME: cannot find $PIDFILE" 1>&2 @@ -292,7 +305,7 @@ if [ "$op" = "stop" -o "$op" = "restart" ];then exit 1 fi fi -fi # stop or restart +fi # stop, restart, reload if [ "$op" = "start" -o "$op" = "restart" ];then oldpid="" -- 2.40.0