Add configuration file parameter "config_directory"

This enables explicit provision of an external configuration file
directory, which if set will be passed to "pg_ctl" as the -D
parameter. Otherwise "pg_ctl" will default to using the data directory,
which will cause some operations to fail if the configuration files
are not present there.

Note this is implemented primarily for feature completeness and for
development/testing purposes. Users who have installed "repmgr" from
a package should not rely on "pg_ctl" to stop/start/restart PostgreSQL,
instead they should set the appropriate "service_..._command" for their
operating system. For more details see:

    https://repmgr.org/docs/4.0/configuration-service-commands.html

Note: in a future release, the presence of "config_directory" in repmgr.conf
will be used to implictly set "--copy-external-config-files=samepath" when
cloning a standby; this is a behaviour change so will be implemented in the
next major realease (repmgr 4.1).

Implements GitHub #424.
This commit is contained in:
Ian Barwick
2018-04-25 11:49:22 +09:00
parent 242fa287b4
commit 3364f8bdf0
7 changed files with 63 additions and 10 deletions

View File

@@ -73,7 +73,7 @@ static char local_repmgr_tmp_directory[MAXPGPATH];
static char datadir_list_filename[MAXLEN];
static char barman_command_buf[MAXLEN] = "";
static void _do_standby_promote_internal(PGconn *conn, const char *data_dir);
static void _do_standby_promote_internal(PGconn *conn);
static void _do_create_recovery_conf(void);
static void check_barman_config(void);
@@ -1957,13 +1957,12 @@ do_standby_promote(void)
PQfinish(current_primary_conn);
_do_standby_promote_internal(conn, config_file_options.data_directory);
_do_standby_promote_internal(conn);
}
static void
_do_standby_promote_internal(PGconn *conn, const char *data_dir)
_do_standby_promote_internal(PGconn *conn)
{
char script[MAXLEN];
int r,
@@ -1975,7 +1974,9 @@ _do_standby_promote_internal(PGconn *conn, const char *data_dir)
t_node_info local_node_record = T_NODE_INFO_INITIALIZER;
RecordStatus record_status = RECORD_NOT_FOUND;
char data_dir[MAXPGPATH];
get_node_config_directory(data_dir);
/* fetch local node record so we can add detail in log messages */
record_status = get_node_record(conn,
@@ -3636,7 +3637,7 @@ do_standby_switchover(void)
}
/* promote standby (local node) */
_do_standby_promote_internal(local_conn, config_file_options.data_directory);
_do_standby_promote_internal(local_conn);
/*