PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# What to use to start up the postmaster. (If you want the script to wait
-# until the server has started, you could use "pg_ctl start -w" here.
-# But without -w, pg_ctl adds no value.)
+# until the server has started, you could use "pg_ctl start" here.)
DAEMON="$prefix/bin/postmaster"
# What to use to shut down the postmaster
su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
;;
restart)
- su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -w "
+ su -l $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
su -l $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
;;
status)
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# What to use to start up the postmaster. (If you want the script to wait
-# until the server has started, you could use "pg_ctl start -w" here.
-# But without -w, pg_ctl adds no value.)
+# until the server has started, you could use "pg_ctl start" here.)
DAEMON="$prefix/bin/postmaster"
# What to use to shut down the postmaster
;;
restart)
echo -n "Restarting PostgreSQL: "
- su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -w "
+ su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s"
test -e "$PG_OOM_ADJUST_FILE" && echo "$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE"
su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
PATH="$prefix/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
# What to use to start up the postmaster. (If you want the script to wait
-# until the server has started, you could use "pg_ctl start -w" here.
-# But without -w, pg_ctl adds no value.)
+# until the server has started, you could use "pg_ctl start" here.)
DAEMON="$prefix/bin/postmaster"
# What to use to shut down the postmaster
pg_ctl
pg_ctl
pg_ctl
Wait for an operation to complete. This is supported for the
modes start , stop ,
restart , promote ,
- and register .
-
-
- Waiting is the default option for shutdowns, but not startups,
- restarts, or promotions. This is mainly for historical reasons; the
- waiting option is almost always preferable. If waiting is not
- selected, the requested action is triggered, but there is no feedback
- about its success. In that case, the server log file or an external
- monitoring system would have to be used to check the progress and
- success of the operation.
+ and register , and is the default for those modes.
Do not wait for an operation to complete. This is the opposite of the
option -w .
+
+ If waiting is disabled, the requested action is triggered, but there
+ is no feedback about its success. In that case, the server log file
+ or an external monitoring system would have to be used to check the
+ progress and success of the operation.
+
+
+ In prior releases of PostgreSQL, this was the default except for
+ the stop mode.
+
To start the server, waiting until the server is
accepting connections:
To restart the server,
waiting for it to shut down and restart:
#define DEFAULT_WAIT 60
-static bool do_wait = false;
-static bool wait_set = false;
+static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
static bool wait_seconds_arg = false;
static bool silent_mode = false;
printf(_(" -s, --silent only print errors, no informational messages\n"));
printf(_(" -t, --timeout=SECS seconds to wait when using -w option\n"));
printf(_(" -V, --version output version information, then exit\n"));
- printf(_(" -w, --wait wait until operation completes\n"));
+ printf(_(" -w, --wait wait until operation completes (default) \n"));
printf(_(" -W, --no-wait do not wait until operation completes\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("(The default is to wait for shutdown, but not for start or restart.)\n\n"));
break;
case 'w':
do_wait = true;
- wait_set = true;
break;
case 'W':
do_wait = false;
- wait_set = true;
break;
case 'c':
allow_core_files = true;
exit(1);
}
- if (!wait_set)
- {
- if (ctl_command == STOP_COMMAND)
- do_wait = true;
- else
- do_wait = false;
- }
-
if (ctl_command == RELOAD_COMMAND)
{
sig = SIGHUP;
print CONF "listen_addresses = '127.0.0.1'\n";
}
close CONF;
-command_ok([ 'pg_ctl', 'start', '-D', "$tempdir/data", '-w' ],
- 'pg_ctl start -w ');
+command_ok([ 'pg_ctl', 'start', '-D', "$tempdir/data" ],
+ 'pg_ctl start');
# sleep here is because Windows builds can't check postmaster.pid exactly,
# so they may mistake a pre-existing postmaster.pid for one created by the
# postmaster they start. Waiting more than the 2 seconds slop time allowed
# by test_postmaster_connection prevents that mistake.
sleep 3 if ($windows_os);
-command_fails([ 'pg_ctl', 'start', '-D', "$tempdir/data", '-w' ],
- 'second pg_ctl start -w fails');
-command_ok([ 'pg_ctl', 'stop', '-D', "$tempdir/data", '-w' ],
- 'pg_ctl stop -w ');
-command_fails([ 'pg_ctl', 'stop', '-D', "$tempdir/data", '-w' ],
+command_fails([ 'pg_ctl', 'start', '-D', "$tempdir/data" ],
+ 'second pg_ctl start fails');
+command_ok([ 'pg_ctl', 'stop', '-D', "$tempdir/data" ],
+ 'pg_ctl stop');
+command_fails([ 'pg_ctl', 'stop', '-D', "$tempdir/data" ],
'second pg_ctl stop fails');
-command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data", '-w' ],
+command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data" ],
'pg_ctl restart with server not running');
-command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data", '-w' ],
+command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data" ],
'pg_ctl restart with server running');
system_or_bail 'pg_ctl', 'stop', '-D', "$tempdir/data";
is($node_standby->safe_psql('postgres', 'SELECT pg_is_in_recovery()'),
't', 'standby is in recovery');
-command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, 'promote' ],
- 'pg_ctl promote of standby runs');
+command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, '-W', ' promote' ],
+ 'pg_ctl -W promote of standby runs');
ok($node_standby->poll_query_until('postgres', 'SELECT NOT pg_is_in_recovery()'),
'promoted standby is not in recovery');
-# same again with wait option
+# same again with default wait option
$node_standby = get_new_node('standby2');
$node_standby->init_from_backup($node_primary, 'my_backup', has_streaming => 1);
$node_standby->start;
is($node_standby->safe_psql('postgres', 'SELECT pg_is_in_recovery()'),
't', 'standby is in recovery');
-command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, '-w', ' promote' ],
- 'pg_ctl -w promote of standby runs');
+command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, 'promote' ],
+ 'pg_ctl promote of standby runs');
# no wait here
$master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
$master->restart;
-system_or_bail('pg_ctl', '-w', '- D', $standby->data_dir, 'promote');
+system_or_bail('pg_ctl', '-D', $standby->data_dir, 'promote');
$standby->poll_query_until('postgres', "SELECT pg_is_in_recovery() <> true");
$standby->safe_psql('postgres', "create table t11()");
=item $node->start()
-Wrapper for pg_ctl -w start
+Wrapper for pg_ctl start
Start the node and wait until it is ready to accept connections.
my $pgdata = $self->data_dir;
my $name = $self->name;
print("### Starting node \"$name\"\n");
- my $ret = TestLib::system_log('pg_ctl', '-w', '- D', $self->data_dir, '-l',
+ my $ret = TestLib::system_log('pg_ctl', '-D', $self->data_dir, '-l',
$self->logfile, 'start');
if ($ret != 0)
=item $node->restart()
-Wrapper for pg_ctl -w restart
+Wrapper for pg_ctl restart
=cut
my $logfile = $self->logfile;
my $name = $self->name;
print "### Restarting node \"$name\"\n";
- TestLib::system_log('pg_ctl', '-D', $pgdata, '-w', '- l', $logfile,
+ TestLib::system_log('pg_ctl', '-D', $pgdata, '-l', $logfile,
'restart');
$self->_update_pid;
}
=item $node->promote()
-Wrapper for pg_ctl promote -w
+Wrapper for pg_ctl promote
=cut
my $logfile = $self->logfile;
my $name = $self->name;
print "### Promoting node \"$name\"\n";
- TestLib::system_log('pg_ctl', '-D', $pgdata, '-w', '- l', $logfile,
+ TestLib::system_log('pg_ctl', '-D', $pgdata, '-l', $logfile,
'promote');
}
print "\nRunning initdb on old cluster\n\n";
standard_initdb() or exit 1;
print "\nStarting old cluster\n\n";
- my @args = ('pg_ctl', 'start', '-l', "$logdir/postmaster1.log", '-w' );
+ my @args = ('pg_ctl', 'start', '-l', "$logdir/postmaster1.log");
system(@args) == 0 or exit 1;
print "\nCreating databases with names covering most ASCII bytes\n\n";
$bindir, '-B', $bindir);
system(@args) == 0 or exit 1;
print "\nStarting new cluster\n\n";
- @args = ('pg_ctl', '-l', "$logdir/postmaster2.log", '-w', ' start');
+ @args = ('pg_ctl', '-l', "$logdir/postmaster2.log", 'start');
system(@args) == 0 or exit 1;
print "\nSetting up stats on new cluster\n\n";
system(".\\analyze_new_cluster.bat") == 0 or exit 1;