mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 08:56:29 +00:00
repmgrd: add stdout/stderr redirects
This commit is contained in:
31
repmgrd.c
31
repmgrd.c
@@ -63,6 +63,8 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
RecordStatus record_status;
|
RecordStatus record_status;
|
||||||
|
|
||||||
|
FILE *fd;
|
||||||
|
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
/* general options */
|
/* general options */
|
||||||
@@ -221,11 +223,38 @@ main(int argc, char **argv)
|
|||||||
config_file_options.monitoring_history = true;
|
config_file_options.monitoring_history = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fd = freopen("/dev/null", "r", stdin);
|
||||||
|
if (fd == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error reopening stdin to \"/dev/null\":\n %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = freopen("/dev/null", "w", stdout);
|
||||||
|
if (fd == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error reopening stdout to \"/dev/null\":\n %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
logger_init(&config_file_options, progname());
|
logger_init(&config_file_options, progname());
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
logger_set_verbose();
|
logger_set_verbose();
|
||||||
|
|
||||||
|
if (log_type == REPMGR_SYSLOG)
|
||||||
|
{
|
||||||
|
fd = freopen("/dev/null", "w", stderr);
|
||||||
|
|
||||||
|
if (fd == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error reopening stderr to \"/dev/null\":\n %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
log_info(_("connecting to database \"%s\""),
|
log_info(_("connecting to database \"%s\""),
|
||||||
config_file_options.conninfo);
|
config_file_options.conninfo);
|
||||||
|
|
||||||
@@ -334,6 +363,8 @@ main(int argc, char **argv)
|
|||||||
setup_event_handlers();
|
setup_event_handlers();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
start_monitoring();
|
start_monitoring();
|
||||||
|
|
||||||
logger_shutdown();
|
logger_shutdown();
|
||||||
|
|||||||
Reference in New Issue
Block a user