mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
repmgrd: fixes to command line handling
This commit is contained in:
29
repmgrd.c
29
repmgrd.c
@@ -54,8 +54,8 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
char log_level[MAXLEN] = "";
|
char cli_loglevel[MAXLEN] = "";
|
||||||
bool monitoring_history = false;
|
bool cli_monitoring_history = false;
|
||||||
|
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
@@ -145,10 +145,10 @@ main(int argc, char **argv)
|
|||||||
/* -L/--log-level */
|
/* -L/--log-level */
|
||||||
case 'L':
|
case 'L':
|
||||||
{
|
{
|
||||||
int detected_log_level = detect_log_level(optarg);
|
int detected_cli_loglevel = detect_log_level(optarg);
|
||||||
if (detected_log_level != -1)
|
if (detected_cli_loglevel != -1)
|
||||||
{
|
{
|
||||||
strncpy(log_level, optarg, MAXLEN);
|
strncpy(cli_loglevel, optarg, MAXLEN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -167,7 +167,7 @@ main(int argc, char **argv)
|
|||||||
/* legacy options */
|
/* legacy options */
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
monitoring_history = true;
|
cli_monitoring_history = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -183,13 +183,6 @@ main(int argc, char **argv)
|
|||||||
exit_with_cli_errors(&cli_errors);
|
exit_with_cli_errors(&cli_errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some configuration file items can be overriden by command line options */
|
|
||||||
/* Command-line parameter -L/--log-level overrides any setting in config file*/
|
|
||||||
if (*log_level != '\0')
|
|
||||||
{
|
|
||||||
strncpy(config_file_options.loglevel, log_level, MAXLEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tell the logger we're a daemon - this will ensure any output logged
|
* Tell the logger we're a daemon - this will ensure any output logged
|
||||||
* before the logger is initialized will be formatted correctly
|
* before the logger is initialized will be formatted correctly
|
||||||
@@ -204,13 +197,21 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
load_config(config_file, verbose, false, &config_file_options, argv[0]);
|
load_config(config_file, verbose, false, &config_file_options, argv[0]);
|
||||||
|
|
||||||
|
|
||||||
|
/* Some configuration file items can be overriden by command line options */
|
||||||
|
/* Command-line parameter -L/--log-level overrides any setting in config file*/
|
||||||
|
if (*cli_loglevel != '\0')
|
||||||
|
{
|
||||||
|
strncpy(config_file_options.loglevel, cli_loglevel, MAXLEN);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* -m/--monitoring-history, if provided, will override repmgr.conf's
|
* -m/--monitoring-history, if provided, will override repmgr.conf's
|
||||||
* monitoring_history; this is for backwards compatibility as it's
|
* monitoring_history; this is for backwards compatibility as it's
|
||||||
* possible this may be baked into various startup scripts.
|
* possible this may be baked into various startup scripts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (monitoring_history == true)
|
if (cli_monitoring_history == true)
|
||||||
{
|
{
|
||||||
config_file_options.monitoring_history = true;
|
config_file_options.monitoring_history = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user