mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
repmgrd: daemonize process by default
It's hard to imagine a use case where this isn't desirable, but in case, for whatever reason, the user does not wish to daemonize the process, the command line option "--daemonize=false" can be provided. Implements GitHub #458.
This commit is contained in:
1
HISTORY
1
HISTORY
@@ -1,6 +1,7 @@
|
||||
4.1.0 2018-??-??
|
||||
repmgr: add "--missing-slots" check to "repmgr node check" (Ian)
|
||||
repmgrd: create a PID file by default; GitHub #457 (Ian)
|
||||
repmgrd: daemonize process by default; GitHub #458 (Ian)
|
||||
|
||||
4.0.6 2018-06-14
|
||||
repmgr: (witness register) prevent registration of a witness server with the
|
||||
|
||||
@@ -29,9 +29,6 @@ static bool config_file_provided = false;
|
||||
bool config_file_found = false;
|
||||
|
||||
static void _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *warning_list);
|
||||
static bool parse_bool(const char *s,
|
||||
const char *config_item,
|
||||
ItemList *error_list);
|
||||
|
||||
static void _parse_line(char *buf, char *name, char *value);
|
||||
static void parse_event_notifications_list(t_configuration_options *options, const char *arg);
|
||||
@@ -1481,7 +1478,7 @@ repmgr_atoi(const char *value, const char *config_item, ItemList *error_list, in
|
||||
*
|
||||
* https://www.postgresql.org/docs/current/static/config-setting.html
|
||||
*/
|
||||
static bool
|
||||
bool
|
||||
parse_bool(const char *s, const char *config_item, ItemList *error_list)
|
||||
{
|
||||
PQExpBufferData errors;
|
||||
|
||||
@@ -283,6 +283,10 @@ bool reload_config(t_configuration_options *orig_options);
|
||||
|
||||
bool parse_recovery_conf(const char *data_dir, t_recovery_conf *conf);
|
||||
|
||||
bool parse_bool(const char *s,
|
||||
const char *config_item,
|
||||
ItemList *error_list);
|
||||
|
||||
int repmgr_atoi(const char *s,
|
||||
const char *config_item,
|
||||
ItemList *error_list,
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<title>repmgrd enhancements</title>
|
||||
<para>
|
||||
<itemizedlist>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<application>repmgrd</application>: create a PID file by default
|
||||
@@ -44,6 +45,16 @@
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<application>repmgrd</application>: daemonize process by default.
|
||||
In case, for whatever reason, the user does not wish to daemonize the
|
||||
process, provice <option>--daemonize=false</option>.
|
||||
(GitHub #458).
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
<para>
|
||||
<application>repmgrd</application> can be started manually like this:
|
||||
<programlisting>
|
||||
repmgrd -f /etc/repmgr.conf --pid-file /tmp/repmgrd.pid --daemonize</programlisting>
|
||||
repmgrd -f /etc/repmgr.conf --pid-file /tmp/repmgrd.pid</programlisting>
|
||||
and stopped with <command>kill `cat /tmp/repmgrd.pid`</command>. Adjust paths as appropriate.
|
||||
</para>
|
||||
<para>
|
||||
|
||||
12
repmgrd.c
12
repmgrd.c
@@ -36,7 +36,7 @@
|
||||
static char *config_file = NULL;
|
||||
static bool verbose = false;
|
||||
static char pid_file[MAXPGPATH];
|
||||
static bool daemonize = false;
|
||||
static bool daemonize = true;
|
||||
static bool show_pid_file = false;
|
||||
static bool no_pid_file = false;
|
||||
|
||||
@@ -101,7 +101,7 @@ main(int argc, char **argv)
|
||||
{"config-file", required_argument, NULL, 'f'},
|
||||
|
||||
/* daemon options */
|
||||
{"daemonize", no_argument, NULL, 'd'},
|
||||
{"daemonize", optional_argument, NULL, 'd'},
|
||||
{"pid-file", required_argument, NULL, 'p'},
|
||||
{"show-pid-file", no_argument, NULL, 's'},
|
||||
{"no-pid-file", no_argument, NULL, OPT_NO_PID_FILE},
|
||||
@@ -175,7 +175,10 @@ main(int argc, char **argv)
|
||||
/* daemon options */
|
||||
|
||||
case 'd':
|
||||
daemonize = true;
|
||||
if (optarg != NULL)
|
||||
{
|
||||
daemonize = parse_bool(optarg, "-d/--daemonize", &cli_errors);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
@@ -747,7 +750,8 @@ show_help(void)
|
||||
puts("");
|
||||
|
||||
printf(_("Daemon configuration options:\n"));
|
||||
printf(_(" -d, --daemonize detach process from foreground\n"));
|
||||
printf(_(" -d, --daemonize[=true/false]\n"));
|
||||
printf(_(" detach process from foreground (default: true)\n"));
|
||||
printf(_(" -p, --pid-file=PATH use the specified PID file\n"));
|
||||
printf(_(" -s, --show-pid-file show PID file which would be used by the current configuration\n"));
|
||||
printf(_(" --no-pid-file don't write a PID file\n"));
|
||||
|
||||
Reference in New Issue
Block a user