mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 17:06:29 +00:00
repmgrd: handle SIGHUP
This commit is contained in:
@@ -12,8 +12,6 @@
|
|||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
|
||||||
|
|
||||||
static volatile sig_atomic_t got_SIGHUP = false;
|
|
||||||
|
|
||||||
static void do_bdr_failover(NodeInfoList *nodes, t_node_info *monitored_node);
|
static void do_bdr_failover(NodeInfoList *nodes, t_node_info *monitored_node);
|
||||||
static void do_bdr_recovery(NodeInfoList *nodes, t_node_info *monitored_node);
|
static void do_bdr_recovery(NodeInfoList *nodes, t_node_info *monitored_node);
|
||||||
|
|
||||||
@@ -284,6 +282,30 @@ monitor_bdr(void)
|
|||||||
got_SIGHUP = false;
|
got_SIGHUP = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (got_SIGHUP)
|
||||||
|
{
|
||||||
|
log_debug("SIGHUP received");
|
||||||
|
|
||||||
|
if (reload_config(&config_file_options))
|
||||||
|
{
|
||||||
|
PQfinish(local_conn);
|
||||||
|
local_conn = establish_db_connection(config_file_options.conninfo, true);
|
||||||
|
|
||||||
|
if (*config_file_options.log_file)
|
||||||
|
{
|
||||||
|
FILE *fd;
|
||||||
|
|
||||||
|
fd = freopen(config_file_options.log_file, "a", stderr);
|
||||||
|
if (fd == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error reopening stderr to '%s': %s",
|
||||||
|
config_file_options.log_file, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
got_SIGHUP = false;
|
||||||
|
}
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "sleeping %i seconds (\"monitor_interval_secs\")",
|
log_verbose(LOG_DEBUG, "sleeping %i seconds (\"monitor_interval_secs\")",
|
||||||
config_file_options.monitor_interval_secs);
|
config_file_options.monitor_interval_secs);
|
||||||
sleep(config_file_options.monitor_interval_secs);
|
sleep(config_file_options.monitor_interval_secs);
|
||||||
|
|||||||
@@ -357,6 +357,31 @@ monitor_streaming_primary(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (got_SIGHUP)
|
||||||
|
{
|
||||||
|
log_debug("SIGHUP received");
|
||||||
|
|
||||||
|
if (reload_config(&config_file_options))
|
||||||
|
{
|
||||||
|
PQfinish(local_conn);
|
||||||
|
local_conn = establish_db_connection(config_file_options.conninfo, true);
|
||||||
|
|
||||||
|
if (*config_file_options.log_file)
|
||||||
|
{
|
||||||
|
FILE *fd;
|
||||||
|
|
||||||
|
fd = freopen(config_file_options.log_file, "a", stderr);
|
||||||
|
if (fd == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error reopening stderr to '%s': %s",
|
||||||
|
config_file_options.log_file, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
got_SIGHUP = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "sleeping %i seconds (parameter \"monitor_interval_secs\")",
|
log_verbose(LOG_DEBUG, "sleeping %i seconds (parameter \"monitor_interval_secs\")",
|
||||||
config_file_options.monitor_interval_secs);
|
config_file_options.monitor_interval_secs);
|
||||||
@@ -396,7 +421,6 @@ monitor_streaming_standby(void)
|
|||||||
*/
|
*/
|
||||||
if (local_node_info.upstream_node_id == NODE_NOT_FOUND)
|
if (local_node_info.upstream_node_id == NODE_NOT_FOUND)
|
||||||
{
|
{
|
||||||
// XXX check if there's an inactive record(s) and log detail/hint
|
|
||||||
log_error(_("unable to determine an active primary for this cluster, terminating"));
|
log_error(_("unable to determine an active primary for this cluster, terminating"));
|
||||||
PQfinish(local_conn);
|
PQfinish(local_conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
@@ -853,6 +877,30 @@ monitor_streaming_standby(void)
|
|||||||
if (PQstatus(local_conn) == CONNECTION_OK && config_file_options.monitoring_history == true)
|
if (PQstatus(local_conn) == CONNECTION_OK && config_file_options.monitoring_history == true)
|
||||||
update_monitoring_history();
|
update_monitoring_history();
|
||||||
|
|
||||||
|
if (got_SIGHUP)
|
||||||
|
{
|
||||||
|
log_debug("SIGHUP received");
|
||||||
|
|
||||||
|
if (reload_config(&config_file_options))
|
||||||
|
{
|
||||||
|
PQfinish(local_conn);
|
||||||
|
local_conn = establish_db_connection(config_file_options.conninfo, true);
|
||||||
|
|
||||||
|
if (*config_file_options.log_file)
|
||||||
|
{
|
||||||
|
FILE *fd;
|
||||||
|
|
||||||
|
fd = freopen(config_file_options.log_file, "a", stderr);
|
||||||
|
if (fd == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error reopening stderr to '%s': %s",
|
||||||
|
config_file_options.log_file, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
got_SIGHUP = false;
|
||||||
|
}
|
||||||
|
|
||||||
sleep(config_file_options.monitor_interval_secs);
|
sleep(config_file_options.monitor_interval_secs);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void (*_close_connections)(void) = NULL;
|
|||||||
* Record receipt of SIGHUP; will cause configuration file to be reread
|
* Record receipt of SIGHUP; will cause configuration file to be reread
|
||||||
* at the appropriate point in the main loop.
|
* at the appropriate point in the main loop.
|
||||||
*/
|
*/
|
||||||
static volatile sig_atomic_t got_SIGHUP = false;
|
volatile sig_atomic_t got_SIGHUP = false;
|
||||||
|
|
||||||
static void show_help(void);
|
static void show_help(void);
|
||||||
static void show_usage(void);
|
static void show_usage(void);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "portability/instr_time.h"
|
#include "portability/instr_time.h"
|
||||||
|
|
||||||
|
extern volatile sig_atomic_t got_SIGHUP;
|
||||||
extern MonitoringState monitoring_state;
|
extern MonitoringState monitoring_state;
|
||||||
extern instr_time degraded_monitoring_start;
|
extern instr_time degraded_monitoring_start;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user