diff --git a/HISTORY b/HISTORY
index a5553fe0..705b9083 100644
--- a/HISTORY
+++ b/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
diff --git a/configfile.c b/configfile.c
index 785419e8..3690d053 100644
--- a/configfile.c
+++ b/configfile.c
@@ -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;
diff --git a/configfile.h b/configfile.h
index bc948648..f10eba12 100644
--- a/configfile.h
+++ b/configfile.h
@@ -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,
diff --git a/doc/appendix-release-notes.sgml b/doc/appendix-release-notes.sgml
index 9b8b8c26..fb9d5354 100644
--- a/doc/appendix-release-notes.sgml
+++ b/doc/appendix-release-notes.sgml
@@ -37,6 +37,7 @@
repmgrd enhancements
+
repmgrd: create a PID file by default
@@ -44,6 +45,16 @@
+
+
+ repmgrd: daemonize process by default.
+ In case, for whatever reason, the user does not wish to daemonize the
+ process, provice .
+ (GitHub #458).
+
+
+
+
diff --git a/doc/repmgrd-configuration.sgml b/doc/repmgrd-configuration.sgml
index 7463215e..f1cd4c8c 100644
--- a/doc/repmgrd-configuration.sgml
+++ b/doc/repmgrd-configuration.sgml
@@ -159,7 +159,7 @@
repmgrd can be started manually like this:
- repmgrd -f /etc/repmgr.conf --pid-file /tmp/repmgrd.pid --daemonize
+ repmgrd -f /etc/repmgr.conf --pid-file /tmp/repmgrd.pid
and stopped with kill `cat /tmp/repmgrd.pid`. Adjust paths as appropriate.
diff --git a/repmgrd.c b/repmgrd.c
index 6d456918..dfad99f2 100644
--- a/repmgrd.c
+++ b/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"));