diff --git a/config.c b/config.c index f6b47954..befb4ab9 100644 --- a/config.c +++ b/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); /* diff --git a/config.h b/config.h index bc6b92bf..dac706af 100644 --- a/config.h +++ b/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 { diff --git a/repmgr.c b/repmgr.c index 053b1da4..abd0010b 100644 --- a/repmgr.c +++ b/repmgr.c @@ -2671,9 +2671,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); @@ -3145,12 +3148,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 @@ -3886,9 +3892,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)