Witness server - extract explicit port setting from conninfo setting

This makes the '-l/--local-port' option redundant, which is now
marked as deprecated.
This commit is contained in:
Ian Barwick
2015-10-01 09:42:44 +09:00
parent 6da03a6157
commit 1c9121c2d8
3 changed files with 33 additions and 3 deletions

View File

@@ -203,8 +203,11 @@ repmgr will also ask for the superuser password on the witness database so
it can reconnect when needed (the command line option --initdb-no-pwprompt
will set up a password-less superuser).
By default the witness server will listen on port 5499; this value can be overridden
with the -l/--local-port option.
By default the witness server will listen on port 5499; this value can be
overridden by explicitly providing the port number in the conninfo string
in repmgr.conf. (Note that it is also possible to specify the port number
with the -l/--local-port option, however this option is now deprecated and
will be overridden by a port setting in the conninfo string).
Start the repmgrd daemons
-------------------------

View File

@@ -10,6 +10,8 @@
Bugfix: call update_node_record_set_upstream() for STANDBY FOLLOW (Tomas)
Update `repmgr --help` output (per Github report from renard)
Update tablespace remapping in --rsync-only mode for 9.5 and later (Ian)
Deprecate `-l/--local-port` option - the port can be extracted
from the conninfo string in repmgr.conf (Ian)
3.0.1 2015-04-16
Prevent repmgrd from looping infinitely if node was not registered (Ian)

View File

@@ -2003,6 +2003,9 @@ do_witness_create(void)
bool success;
bool record_created;
PQconninfoOption *conninfo_options;
PQconninfoOption *conninfo_option;
/* Connection parameters for master only */
keywords[0] = "host";
values[0] = runtime_options.host;
@@ -2144,6 +2147,27 @@ do_witness_create(void)
xsnprintf(buf, sizeof(buf), "\n#Configuration added by %s\n", progname);
fputs(buf, pg_conf);
/* Attempt to extract a port number from the provided conninfo string
* This will override any value provided with '-l/--local-port', as it's
* what we'll later try and connect to anyway. '-l/--local-port' should
* be deprecated.
*/
conninfo_options = PQconninfoParse(options.conninfo, NULL);
for (conninfo_option = conninfo_options; conninfo_option->keyword != NULL; conninfo_option++)
{
if (strcmp(conninfo_option->keyword, "port") == 0)
{
if (conninfo_option->val != NULL && conninfo_option->val[0] != '\0')
{
strncpy(runtime_options.localport, conninfo_option->val, MAXLEN);
break;
}
}
}
PQconninfoFree(conninfo_options);
/*
* If not specified by the user, the default port for the witness server
* is 5499; this is intended to support running the witness server as
@@ -2434,11 +2458,12 @@ help(const char *progname)
printf(_(" -b, --pg_bindir=PATH path to PostgreSQL binaries (optional)\n"));
printf(_(" -D, --data-dir=DIR local directory where the files will be\n" \
" copied to\n"));
printf(_(" -l, --local-port=PORT witness server local port (default: %s)\n"), WITNESS_DEFAULT_PORT);
printf(_(" -f, --config-file=PATH path to the configuration file\n"));
printf(_(" -R, --remote-user=USERNAME database server username for rsync\n"));
printf(_(" -S, --superuser=USERNAME superuser username for witness database\n" \
" (default: postgres)\n"));
/* remove this line in the next significant release */
printf(_(" -l, --local-port=PORT (DEPRECATED) witness server local port (default: %s)\n"), WITNESS_DEFAULT_PORT);
printf(_(" -w, --wal-keep-segments=VALUE minimum value for the GUC\n" \
" wal_keep_segments (default: %s)\n"), DEFAULT_WAL_KEEP_SEGMENTS);
printf(_(" -k, --keep-history=VALUE keeps indicated number of days of history\n"));