mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
added config options pg_bindir and pg_ctl_options
This commit is contained in:
12
config.c
12
config.c
@@ -42,6 +42,8 @@ parse_config(const char *config_file, t_configuration_options *options)
|
||||
memset(options->follow_command, 0, sizeof(options->follow_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));
|
||||
memset(options->pgctl_options, 0, sizeof(options->pgctl_options));
|
||||
|
||||
/* if nothing has been provided defaults to 60 */
|
||||
options->master_response_timeout = 60;
|
||||
@@ -114,6 +116,10 @@ parse_config(const char *config_file, t_configuration_options *options)
|
||||
options->reconnect_attempts = atoi(value);
|
||||
else if (strcmp(name, "reconnect_interval") == 0)
|
||||
options->reconnect_intvl = atoi(value);
|
||||
else if (strcmp(name, "pg_bindir") == 0)
|
||||
strncpy (options->pg_bindir, value, MAXLEN);
|
||||
else if (strcmp(name, "pg_ctl_options") == 0)
|
||||
strncpy (options->pgctl_options, value, MAXLEN);
|
||||
else
|
||||
log_warning(_("%s/%s: Unknown name/value pair!\n"), name, value);
|
||||
}
|
||||
@@ -151,6 +157,12 @@ parse_config(const char *config_file, t_configuration_options *options)
|
||||
log_err(_("Reconnect intervals must be zero or greater. Check the configuration file.\n"));
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
if (*options->pg_bindir == '\0')
|
||||
{
|
||||
log_err(_("pg_bindir config value not found. Check the configuration file.\n"));
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
2
config.h
2
config.h
@@ -40,6 +40,8 @@ typedef struct
|
||||
int master_response_timeout;
|
||||
int reconnect_attempts;
|
||||
int reconnect_intvl;
|
||||
char pg_bindir[MAXLEN];
|
||||
char pgctl_options[MAXLEN];
|
||||
} t_configuration_options;
|
||||
|
||||
void parse_config(const char *config_file, t_configuration_options *options);
|
||||
|
||||
19
repmgr.c
19
repmgr.c
@@ -86,7 +86,7 @@ bool require_password = false;
|
||||
|
||||
/* Initialization of runtime options */
|
||||
t_runtime_options runtime_options = { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, "", "", 0 };
|
||||
t_configuration_options options = { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1 };
|
||||
t_configuration_options options = { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "" };
|
||||
|
||||
static char *server_mode = NULL;
|
||||
static char *server_cmd = NULL;
|
||||
@@ -1317,13 +1317,12 @@ do_standby_promote(void)
|
||||
rename(recovery_file_path, recovery_done_path);
|
||||
|
||||
/*
|
||||
* We assume the pg_ctl script is in the PATH. Restart and wait for
|
||||
* the server to finish starting, so that the check below will
|
||||
* find an active server rather than one starting up. This may
|
||||
* Restart and wait for the server to finish starting, so that the check
|
||||
* below will find an active server rather than one starting up. This may
|
||||
* hang for up the default timeout (60 seconds).
|
||||
*/
|
||||
log_notice(_("%s: restarting server using pg_ctl\n"), progname);
|
||||
maxlen_snprintf(script, "pg_ctl -D %s -w -m fast restart", data_dir);
|
||||
log_notice(_("%s: restarting server using %s/pg_ctl\n"), progname, options.pg_bindir);
|
||||
maxlen_snprintf(script, "%s/pg_ctl %s -D %s -w -m fast restart", options.pg_bindir, options.pgctl_options, data_dir);
|
||||
r = system(script);
|
||||
if (r != 0)
|
||||
{
|
||||
@@ -1468,8 +1467,7 @@ do_standby_follow(void)
|
||||
exit(ERR_BAD_CONFIG);
|
||||
|
||||
/* Finally, restart the service */
|
||||
/* We assume the pg_ctl script is in the PATH */
|
||||
maxlen_snprintf(script, "pg_ctl -w -D %s -m fast restart", data_dir);
|
||||
maxlen_snprintf(script, "%s/pg_ctl %s -w -D %s -m fast restart", options.pg_bindir, options.pgctl_options, data_dir);
|
||||
r = system(script);
|
||||
if (r != 0)
|
||||
{
|
||||
@@ -1558,8 +1556,7 @@ do_witness_create(void)
|
||||
*/
|
||||
|
||||
/* Create the cluster for witness */
|
||||
/* We assume the pg_ctl script is in the PATH */
|
||||
sprintf(script, "pg_ctl -D %s init -o \"-W\"", runtime_options.dest_dir);
|
||||
sprintf(script, "%s/pg_ctl %s -D %s init -o \"-W\"", options.pg_bindir, options.pgctl_options, runtime_options.dest_dir);
|
||||
log_info("Initialize cluster for witness: %s.\n", script);
|
||||
|
||||
r = system(script);
|
||||
@@ -1632,7 +1629,7 @@ do_witness_create(void)
|
||||
}
|
||||
|
||||
/* start new instance */
|
||||
sprintf(script, "pg_ctl -w -D %s start", runtime_options.dest_dir);
|
||||
sprintf(script, "%s/pg_ctl %s -w -D %s start", options.pg_bindir, options.pgctl_options, runtime_options.dest_dir);
|
||||
log_info(_("Start cluster for witness: %s"), script);
|
||||
r = system(script);
|
||||
if (r != 0)
|
||||
|
||||
@@ -34,3 +34,11 @@ loglevel=NOTICE
|
||||
# Logging facility: possible values are STDERR or - for Syslog integration - one of LOCAL0, LOCAL1, ..., LOCAL7, USER
|
||||
# Default: STDERR
|
||||
logfacility=STDERR
|
||||
|
||||
# path to pg_ctl executable
|
||||
pg_bindir=/usr/bin/
|
||||
|
||||
#
|
||||
# you may add command line arguments for pg_ctl
|
||||
#
|
||||
# pg_ctl_options='-s'
|
||||
Reference in New Issue
Block a user