mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
write standby.signal
This commit is contained in:
@@ -1946,7 +1946,7 @@ modify_auto_conf(const char *data_dir, KeyValueList *items)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fwrite(auto_conf_contents.data, strlen(auto_conf_contents.data) + 1, 1, fp) != 1)
|
if (fwrite(auto_conf_contents.data, strlen(auto_conf_contents.data), 1, fp) != 1)
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6956,9 +6956,12 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *primary_co
|
|||||||
|
|
||||||
initPQExpBuffer(&primary_conninfo_buf);
|
initPQExpBuffer(&primary_conninfo_buf);
|
||||||
|
|
||||||
/* standby_mode = 'on' */
|
/* standby_mode = 'on' (Pg 11 and earlier) */
|
||||||
key_value_list_set(&recovery_config,
|
if (source_server_version_num < 120000)
|
||||||
"standby_mode", "on");
|
{
|
||||||
|
key_value_list_set(&recovery_config,
|
||||||
|
"standby_mode", "on");
|
||||||
|
}
|
||||||
|
|
||||||
/* primary_conninfo = '...' */
|
/* primary_conninfo = '...' */
|
||||||
write_primary_conninfo(&primary_conninfo_buf, primary_conninfo);
|
write_primary_conninfo(&primary_conninfo_buf, primary_conninfo);
|
||||||
@@ -7036,7 +7039,51 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *primary_co
|
|||||||
*/
|
*/
|
||||||
if (source_server_version_num >= 120000)
|
if (source_server_version_num >= 120000)
|
||||||
{
|
{
|
||||||
return modify_auto_conf(dest, &recovery_config);
|
char standby_signal_file_path[MAXPGPATH] = "";
|
||||||
|
FILE *file;
|
||||||
|
|
||||||
|
if (modify_auto_conf(dest, &recovery_config) == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create standby.signal */
|
||||||
|
|
||||||
|
snprintf(standby_signal_file_path, MAXPGPATH,
|
||||||
|
"%s/%s",
|
||||||
|
config_file_options.data_directory,
|
||||||
|
STANDBY_SIGNAL_FILE);
|
||||||
|
|
||||||
|
/* Set umask to 0600 */
|
||||||
|
um = umask((~(S_IRUSR | S_IWUSR)) & (S_IRWXG | S_IRWXO));
|
||||||
|
file = fopen(standby_signal_file_path, "w");
|
||||||
|
umask(um);
|
||||||
|
|
||||||
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
log_error(_("unable to create %s file at \"%s\""),
|
||||||
|
STANDBY_SIGNAL_FILE,
|
||||||
|
standby_signal_file_path);
|
||||||
|
log_detail("%s", strerror(errno));
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// write "created by repmgr" or something
|
||||||
|
if (fputs("# foo", file) == EOF)
|
||||||
|
{
|
||||||
|
log_error(_("unable to write to %s file at \"%s\""),
|
||||||
|
STANDBY_SIGNAL_FILE,
|
||||||
|
standby_signal_file_path);
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
5
repmgr.h
5
repmgr.h
@@ -109,6 +109,11 @@
|
|||||||
#define RECOVERY_COMMAND_FILE "recovery.conf"
|
#define RECOVERY_COMMAND_FILE "recovery.conf"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef STANDBY_SIGNAL_FILE
|
||||||
|
#define STANDBY_SIGNAL_FILE "standby.signal"
|
||||||
|
#define RECOVERY_SIGNAL_FILE "recovery.signal"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TABLESPACE_MAP
|
#ifndef TABLESPACE_MAP
|
||||||
#define TABLESPACE_MAP "tablespace_map"
|
#define TABLESPACE_MAP "tablespace_map"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user