From 388ac2f3928d59eaca155314eb54cbb3db10cd59 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 13 Jul 2018 10:26:47 +0900 Subject: [PATCH] repmgrd: enable package to supply default PID file path Also add documentation for packagers about paths which can be patched as default package values. --- doc/appendix-packages.sgml | 44 ++++++++++++++++++++++++++++++++++ doc/repmgrd-configuration.sgml | 19 +++++++++++---- repmgrd.c | 18 ++++++++++---- 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/doc/appendix-packages.sgml b/doc/appendix-packages.sgml index 8b7b362a..79e5ffd5 100644 --- a/doc/appendix-packages.sgml +++ b/doc/appendix-packages.sgml @@ -364,4 +364,48 @@ + + + + Information for packagers + + packages + information for packagers + + + We recommend patching the following parameters when + building the package as built-in default values for user convenience. + These values can nevertheless be overridden by the user, if desired. + + + + + Configuration file location: the default configuration file location + can be hard-coded by patching package_conf_file + in configfile.c: + + /* packagers: if feasible, patch configuration file path into "package_conf_file" */ + char package_conf_file[MAXPGPATH] = ""; + + + See also: + + + + + + PID file location: the default repmgrd PID file + location can be hard-coded by patching package_pid_file + in repmgrd.c: + + /* packagers: if feasible, patch PID file path into "package_pid_file" */ + char package_pid_file[MAXPGPATH] = ""; + + + See also: + + + + + diff --git a/doc/repmgrd-configuration.sgml b/doc/repmgrd-configuration.sgml index 750e49d3..eebe308f 100644 --- a/doc/repmgrd-configuration.sgml +++ b/doc/repmgrd-configuration.sgml @@ -170,11 +170,15 @@ running repmgrd daemon. - + repmgrd PID file + + PID file + repmgrd + repmgrd's PID file repmgrd will generate a PID file by default. @@ -197,16 +201,21 @@ may be deprecated in future releases. - If no PID file is specified, repmgrd will create one - in the operating system's temporary directory (determined by the environment variable - TMPDIR, or if that is not set, will use /tmp. + If a PID file location was specified by the package maintainer, repmgrd + will use that. This only applies if &repmgr; was installed from a package and the package + maintainer has specified the PID file location. + + + If none of the above apply, repmgrd will create a PID file + in the operating system's temporary directory (das etermined by the environment variable + TMPDIR, or if that is not set, will use /tmp). To prevent a PID file being generated at all, provide the command line option . - To see which PID file would use, execute repmgrd + To see which PID file repmgrd would use, execute repmgrd with the option . repmgrd will not start if this option is provided. Note that the value shown is the file repmgrd would use next time it starts, and is diff --git a/repmgrd.c b/repmgrd.c index 457dc916..a985b5dd 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -275,12 +275,22 @@ main(int argc, char **argv) /* no pid file provided - determine location */ if (pid_file[0] == '\0') { - const char *tmpdir = getenv("TMPDIR"); + /* packagers: if feasible, patch PID file path into "package_pid_file" */ + char package_pid_file[MAXPGPATH] = ""; - if (!tmpdir) - tmpdir = "/tmp"; + if (package_pid_file[0] != '\0') + { + maxpath_snprintf(pid_file, "%s", package_pid_file); + } + else + { + const char *tmpdir = getenv("TMPDIR"); - maxpath_snprintf(pid_file, "%s/repmgrd.pid", tmpdir); + if (!tmpdir) + tmpdir = "/tmp"; + + maxpath_snprintf(pid_file, "%s/repmgrd.pid", tmpdir); + } } } else