mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Allow overriding start, stop and restart commands issued by repmgr
This commit introduces three new options: - start_command - stop_command - restart_command If these are set, repmgr will issue the specified command instead of the default pg_ctl commands
This commit is contained in:
9
config.c
9
config.c
@@ -219,6 +219,9 @@ parse_config(t_configuration_options *options)
|
||||
memset(options->node_name, 0, sizeof(options->node_name));
|
||||
memset(options->promote_command, 0, sizeof(options->promote_command));
|
||||
memset(options->follow_command, 0, sizeof(options->follow_command));
|
||||
memset(options->stop_command, 0, sizeof(options->stop_command));
|
||||
memset(options->start_command, 0, sizeof(options->start_command));
|
||||
memset(options->restart_command, 0, sizeof(options->restart_command));
|
||||
memset(options->rsync_options, 0, sizeof(options->rsync_options));
|
||||
memset(options->ssh_options, 0, sizeof(options->ssh_options));
|
||||
memset(options->pg_bindir, 0, sizeof(options->pg_bindir));
|
||||
@@ -341,6 +344,12 @@ parse_config(t_configuration_options *options)
|
||||
strncpy(options->promote_command, value, MAXLEN);
|
||||
else if (strcmp(name, "follow_command") == 0)
|
||||
strncpy(options->follow_command, value, MAXLEN);
|
||||
else if (strcmp(name, "stop_command") == 0)
|
||||
strncpy(options->stop_command, value, MAXLEN);
|
||||
else if (strcmp(name, "start_command") == 0)
|
||||
strncpy(options->start_command, value, MAXLEN);
|
||||
else if (strcmp(name, "restart_command") == 0)
|
||||
strncpy(options->restart_command, value, MAXLEN);
|
||||
else if (strcmp(name, "master_response_timeout") == 0)
|
||||
options->master_response_timeout = repmgr_atoi(value, "master_response_timeout", &config_errors, false);
|
||||
/*
|
||||
|
||||
5
config.h
5
config.h
@@ -62,6 +62,9 @@ typedef struct
|
||||
char node_name[MAXLEN];
|
||||
char promote_command[MAXLEN];
|
||||
char follow_command[MAXLEN];
|
||||
char stop_command[MAXLEN];
|
||||
char start_command[MAXLEN];
|
||||
char restart_command[MAXLEN];
|
||||
char loglevel[MAXLEN];
|
||||
char logfacility[MAXLEN];
|
||||
char rsync_options[QUERY_STR_LEN];
|
||||
@@ -87,7 +90,7 @@ typedef struct
|
||||
* The following will initialize the structure with a minimal set of options;
|
||||
* actual defaults are set in parse_config() before parsing the configuration file
|
||||
*/
|
||||
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, { NULL, NULL } }
|
||||
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, {NULL, NULL} }
|
||||
|
||||
typedef struct ErrorListCell
|
||||
{
|
||||
|
||||
24
repmgr.c
24
repmgr.c
@@ -2799,9 +2799,12 @@ do_standby_follow(void)
|
||||
exit(ERR_BAD_CONFIG);
|
||||
|
||||
/* Finally, restart the service */
|
||||
maxlen_snprintf(script, "%s %s -w -D %s -m fast restart",
|
||||
make_pg_path("pg_ctl"), options.pg_ctl_options, data_dir);
|
||||
|
||||
if (*options.restart_command) {
|
||||
maxlen_snprintf(script, "%s", options.restart_command);
|
||||
} else {
|
||||
maxlen_snprintf(script, "%s %s -w -D %s -m fast restart",
|
||||
make_pg_path("pg_ctl"), options.pg_ctl_options, data_dir);
|
||||
}
|
||||
log_notice(_("restarting server using '%s'\n"),
|
||||
script);
|
||||
|
||||
@@ -3279,12 +3282,15 @@ do_standby_switchover(void)
|
||||
* -> use -F/--force?
|
||||
*/
|
||||
|
||||
if (*options.stop_command) {
|
||||
maxlen_snprintf(command, "%s", options.stop_command);
|
||||
} else {
|
||||
maxlen_snprintf(command,
|
||||
"%s -D %s -m %s -W stop >/dev/null 2>&1 && echo 1 || echo 0",
|
||||
make_pg_path("pg_ctl"),
|
||||
remote_data_directory,
|
||||
runtime_options.pg_ctl_mode);
|
||||
|
||||
}
|
||||
initPQExpBuffer(&command_output);
|
||||
|
||||
// XXX handle failure
|
||||
@@ -4044,9 +4050,13 @@ do_witness_create(void)
|
||||
|
||||
|
||||
/* start new instance */
|
||||
maxlen_snprintf(script, "%s %s -w -D %s start",
|
||||
make_pg_path("pg_ctl"),
|
||||
options.pg_ctl_options, runtime_options.dest_dir);
|
||||
if (*options.start_command) {
|
||||
maxlen_snprintf(script, "%s", options.start_command);
|
||||
} else {
|
||||
maxlen_snprintf(script, "%s %s -w -D %s start",
|
||||
make_pg_path("pg_ctl"),
|
||||
options.pg_ctl_options, runtime_options.dest_dir);
|
||||
}
|
||||
log_info(_("starting witness server: %s\n"), script);
|
||||
r = system(script);
|
||||
if (r != 0)
|
||||
|
||||
Reference in New Issue
Block a user