mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Rename some "repmgr daemon ..." commands to "repmgr service ..."
"repmgr daemon" can be interpreted to mean the commands affect the local daemon process only. Rename the commands which affect the entire cluster to "repmgr service ...". The "repmgr daemon ..." form of the affected commands is retained for backwards compatibility.
This commit is contained in:
768
daemon-start-stop.patch
Normal file
768
daemon-start-stop.patch
Normal file
@@ -0,0 +1,768 @@
|
||||
diff --git a/Makefile.in b/Makefile.in
|
||||
index 2700a78..108bfe8 100644
|
||||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -53,7 +53,7 @@ $(info Building against PostgreSQL $(MAJORVERSION))
|
||||
|
||||
REPMGR_CLIENT_OBJS = repmgr-client.o \
|
||||
repmgr-action-primary.o repmgr-action-standby.o repmgr-action-witness.o \
|
||||
- repmgr-action-bdr.o repmgr-action-cluster.o repmgr-action-node.o repmgr-action-service.o \
|
||||
+ repmgr-action-bdr.o repmgr-action-cluster.o repmgr-action-node.o repmgr-action-service.o repmgr-action-daemon.o \
|
||||
configfile.o configfile-scan.o log.o strutil.o controldata.o dirutil.o compat.o dbutils.o sysutils.o
|
||||
REPMGRD_OBJS = repmgrd.o repmgrd-physical.o repmgrd-bdr.o configfile.o configfile-scan.o log.o dbutils.o strutil.o controldata.o compat.o sysutils.o
|
||||
DATE=$(shell date "+%Y-%m-%d")
|
||||
diff --git a/doc/appendix-release-notes.xml b/doc/appendix-release-notes.xml
|
||||
index 93e5a8c..e5fe4e0 100644
|
||||
--- a/doc/appendix-release-notes.xml
|
||||
+++ b/doc/appendix-release-notes.xml
|
||||
@@ -24,12 +24,9 @@
|
||||
<sect2>
|
||||
<title>Compatibility changes</title>
|
||||
<para>
|
||||
- The <command>repmgr daemon ...</command> commands have been renamed to
|
||||
- <command>repmgr service ...</command>.
|
||||
- </para>
|
||||
- <para>
|
||||
- The <command>repmgr daemon ...</command> form will still be accepted
|
||||
- for backwards compatibility.
|
||||
+ Some <command>repmgr daemon ...</command> commands have been renamed to
|
||||
+ <command>repmgr service ...</command> as they have a cluster-wide effect
|
||||
+ and to avoid giving the impression they affect only the local &repmgr; daemon.
|
||||
</para>
|
||||
<para>
|
||||
Following commands are affected:
|
||||
@@ -57,22 +54,13 @@
|
||||
</simpara>
|
||||
</listitem>
|
||||
|
||||
- <listitem>
|
||||
- <simpara>
|
||||
- <command>repmgr daemon start</command>
|
||||
- (now <link linkend="repmgr-service-start"><command>repmgr service start</command></link>)
|
||||
- </simpara>
|
||||
- </listitem>
|
||||
-
|
||||
- <listitem>
|
||||
- <simpara>
|
||||
- <command>repmgr daemon stop</command>
|
||||
- (now <link linkend="repmgr-service-stop"><command>repmgr service stop</command></link>)
|
||||
- </simpara>
|
||||
- </listitem>
|
||||
-
|
||||
</itemizedlist>
|
||||
</para>
|
||||
+ <para>
|
||||
+ The <command>repmgr daemon ...</command> form will still be accepted
|
||||
+ for backwards compatibility.
|
||||
+ </para>
|
||||
+
|
||||
|
||||
<para>
|
||||
The following command line options, which have been deprecated since &repmgr; 3.3
|
||||
@@ -497,8 +485,8 @@ REPMGRD_OPTS="--daemonize=false"</programlisting>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
- New commands <link linkend="repmgr-service-start"><command>repmgr daemon start</command></link> and
|
||||
- <link linkend="repmgr-service-stop"><command>repmgr daemon stop</command></link>:
|
||||
+ New commands <link linkend="repmgr-daemon-start"><command>repmgr daemon start</command></link> and
|
||||
+ <link linkend="repmgr-daemon-stop"><command>repmgr daemon stop</command></link>:
|
||||
these provide a standardized way of starting and stopping &repmgrd;.
|
||||
GitHub #528.
|
||||
</para>
|
||||
diff --git a/doc/filelist.xml b/doc/filelist.xml
|
||||
index e59e35d..b2bb157 100644
|
||||
--- a/doc/filelist.xml
|
||||
+++ b/doc/filelist.xml
|
||||
@@ -55,10 +55,10 @@
|
||||
<!ENTITY repmgr-cluster-event SYSTEM "repmgr-cluster-event.xml">
|
||||
<!ENTITY repmgr-cluster-cleanup SYSTEM "repmgr-cluster-cleanup.xml">
|
||||
<!ENTITY repmgr-service-status SYSTEM "repmgr-service-status.xml">
|
||||
-<!ENTITY repmgr-service-start SYSTEM "repmgr-service-start.xml">
|
||||
-<!ENTITY repmgr-service-stop SYSTEM "repmgr-service-stop.xml">
|
||||
<!ENTITY repmgr-service-pause SYSTEM "repmgr-service-pause.xml">
|
||||
<!ENTITY repmgr-service-unpause SYSTEM "repmgr-service-unpause.xml">
|
||||
+<!ENTITY repmgr-daemon-start SYSTEM "repmgr-daemon-start.xml">
|
||||
+<!ENTITY repmgr-daemon-stop SYSTEM "repmgr-daemon-stop.xml">
|
||||
|
||||
<!ENTITY appendix-release-notes SYSTEM "appendix-release-notes.xml">
|
||||
<!ENTITY appendix-faq SYSTEM "appendix-faq.xml">
|
||||
diff --git a/doc/repmgr-daemon-start.xml b/doc/repmgr-daemon-start.xml
|
||||
index ae5e21f..fb0eb6d 100644
|
||||
--- a/doc/repmgr-daemon-start.xml
|
||||
+++ b/doc/repmgr-daemon-start.xml
|
||||
@@ -1,6 +1,6 @@
|
||||
-<refentry id="repmgr-service-start">
|
||||
+<refentry id="repmgr-daemon-start">
|
||||
<indexterm>
|
||||
- <primary>repmgr service start</primary>
|
||||
+ <primary>repmgr daemon start</primary>
|
||||
</indexterm>
|
||||
|
||||
<indexterm>
|
||||
@@ -9,11 +9,11 @@
|
||||
</indexterm>
|
||||
|
||||
<refmeta>
|
||||
- <refentrytitle>repmgr service start</refentrytitle>
|
||||
+ <refentrytitle>repmgr daemon start</refentrytitle>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
- <refname>repmgr service start</refname>
|
||||
+ <refname>repmgr daemon start</refname>
|
||||
<refpurpose>Start the &repmgrd; service</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
<important>
|
||||
<para>
|
||||
The <filename>repmgr.conf</filename> parameter <varname>repmgrd_service_start_command</varname>
|
||||
- must be set for <command>repmgr service start</command> to work; see section
|
||||
- <xref linkend="repmgr-service-start-configuration"/> for details.
|
||||
+ must be set for <command>repmgr daemon start</command> to work; see section
|
||||
+ <xref linkend="repmgr-daemon-start-configuration"/> for details.
|
||||
</para>
|
||||
</important>
|
||||
</refsect1>
|
||||
@@ -89,11 +89,11 @@
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
- <refsect1 id="repmgr-service-start-configuration" xreflabel="repmgr service start configuration">
|
||||
+ <refsect1 id="repmgr-daemon-start-configuration" xreflabel="repmgr daemon start configuration">
|
||||
<title>Configuration file settings</title>
|
||||
<para>
|
||||
The following parameter in <filename>repmgr.conf</filename> is relevant
|
||||
- to <command>repmgr service start</command>:
|
||||
+ to <command>repmgr daemon start</command>:
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
@@ -104,11 +104,11 @@
|
||||
<listitem>
|
||||
<indexterm>
|
||||
<primary>repmgrd_service_start_command</primary>
|
||||
- <secondary>with "repmgr service start"</secondary>
|
||||
+ <secondary>with "repmgr daemon start"</secondary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
- <command>repmgr service start</command> will execute the command defined by the
|
||||
+ <command>repmgr daemon start</command> will execute the command defined by the
|
||||
<varname>repmgrd_service_start_command</varname> parameter in <filename>repmgr.conf</filename>.
|
||||
This must be set to a shell command which will start &repmgrd;;
|
||||
if &repmgr; was installed from a package, this will be the service command defined by the
|
||||
@@ -132,7 +132,7 @@
|
||||
<refsect1>
|
||||
<title>Exit codes</title>
|
||||
<para>
|
||||
- One of the following exit codes will be emitted by <command>repmgr service start</command>:
|
||||
+ One of the following exit codes will be emitted by <command>repmgr daemon start</command>:
|
||||
</para>
|
||||
<variablelist>
|
||||
|
||||
@@ -197,7 +197,7 @@
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
<para>
|
||||
- <xref linkend="repmgr-service-stop"/>, <xref linkend="repmgr-service-status"/>, <xref linkend="repmgrd-daemon"/>
|
||||
+ <xref linkend="repmgr-daemon-stop"/>, <xref linkend="repmgrd-daemon"/>, <xref linkend="repmgr-service-status"/>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
diff --git a/doc/repmgr-daemon-stop.xml b/doc/repmgr-daemon-stop.xml
|
||||
index dc93856..2304201 100644
|
||||
--- a/doc/repmgr-daemon-stop.xml
|
||||
+++ b/doc/repmgr-daemon-stop.xml
|
||||
@@ -1,4 +1,4 @@
|
||||
-<refentry id="repmgr-service-stop">
|
||||
+<refentry id="repmgr-daemon-stop">
|
||||
<indexterm>
|
||||
<primary>repmgr daemon stop</primary>
|
||||
</indexterm>
|
||||
@@ -40,7 +40,7 @@
|
||||
<para>
|
||||
The <filename>repmgr.conf</filename> parameter <varname>repmgrd_service_stop_command</varname>
|
||||
must be set for <command>repmgr daemon stop</command> to work; see section
|
||||
- <xref linkend="repmgr-service-stop-configuration"/> for details.
|
||||
+ <xref linkend="repmgr-daemon-stop-configuration"/> for details.
|
||||
</para>
|
||||
</important>
|
||||
</refsect1>
|
||||
@@ -114,7 +114,7 @@
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
- <refsect1 id="repmgr-service-stop-configuration" xreflabel="repmgr daemon stop configuration">
|
||||
+ <refsect1 id="repmgr-daemon-stop-configuration" xreflabel="repmgr daemon stop configuration">
|
||||
<title>Configuration file settings</title>
|
||||
<para>
|
||||
The following parameter in <filename>repmgr.conf</filename> is relevant
|
||||
@@ -194,7 +194,7 @@
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
<para>
|
||||
- <xref linkend="repmgr-service-start"/>, <xref linkend="repmgr-service-status"/>, <xref linkend="repmgrd-daemon"/>
|
||||
+ <xref linkend="repmgr-daemon-start"/>, <xref linkend="repmgrd-daemon"/>, <xref linkend="repmgr-service-status"/>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
diff --git a/doc/repmgr.xml b/doc/repmgr.xml
|
||||
index d3dc3b7..5de1178 100644
|
||||
--- a/doc/repmgr.xml
|
||||
+++ b/doc/repmgr.xml
|
||||
@@ -117,10 +117,10 @@
|
||||
&repmgr-cluster-event;
|
||||
&repmgr-cluster-cleanup;
|
||||
&repmgr-service-status;
|
||||
- &repmgr-service-start;
|
||||
- &repmgr-service-stop;
|
||||
&repmgr-service-pause;
|
||||
&repmgr-service-unpause;
|
||||
+ &repmgr-daemon-start;
|
||||
+ &repmgr-daemon-stop;
|
||||
</part>
|
||||
|
||||
&appendix-release-notes;
|
||||
diff --git a/doc/repmgrd-configuration.xml b/doc/repmgrd-configuration.xml
|
||||
index d674e4e..dd28650 100644
|
||||
--- a/doc/repmgrd-configuration.xml
|
||||
+++ b/doc/repmgrd-configuration.xml
|
||||
@@ -518,10 +518,8 @@
|
||||
<secondary>repmgrd service configuration</secondary>
|
||||
</indexterm>
|
||||
<para>
|
||||
- If you are intending to use the <link linkend="repmgr-service-start"><command>repmgr service start</command></link>
|
||||
- and <link linkend="repmgr-service-stop"><command>repmgr service stop</command></link>
|
||||
- (&repmgr; 4.2 - 4.4: <link linkend="repmgr-service-start"><command>repmgr daemon start</command></link>
|
||||
- and <link linkend="repmgr-service-stop"><command>repmgr daemon stop</command></link>)
|
||||
+ If you are intending to use the <link linkend="repmgr-daemon-start"><command>repmgr daemon start</command></link>
|
||||
+ and <link linkend="repmgr-daemon-stop"><command>repmgr daemon stop</command></link>
|
||||
commands, the following
|
||||
parameters <emphasis>must</emphasis> be set in <filename>repmgr.conf</filename>:
|
||||
<itemizedlist spacing="compact" mark="bullet">
|
||||
@@ -861,14 +859,14 @@ repmgrd_service_stop_command='sudo systemctl repmgr11 stop'
|
||||
for different distributions.
|
||||
</para>
|
||||
<para>
|
||||
- The commands <link linkend="repmgr-service-start"><command>repmgr service start</command></link> and
|
||||
- <link linkend="repmgr-service-stop"><command>repmgr service stop</command></link> can be used
|
||||
+ The commands <link linkend="repmgr-daemon-start"><command>repmgr daemon start</command></link> and
|
||||
+ <link linkend="repmgr-daemon-stop"><command>repmgr daemon stop</command></link> can be used
|
||||
as convenience wrappers to start and stop &repmgrd; on the local node.
|
||||
</para>
|
||||
<important>
|
||||
<para>
|
||||
- <link linkend="repmgr-service-start"><command>repmgr daemon start</command></link> and
|
||||
- <link linkend="repmgr-service-stop"><command>repmgr daemon stop</command></link> require
|
||||
+ <link linkend="repmgr-daemon-start"><command>repmgr daemon start</command></link> and
|
||||
+ <link linkend="repmgr-daemon-stop"><command>repmgr daemon stop</command></link> require
|
||||
that the appropriate start/stop commands are configured as
|
||||
<varname>repmgrd_service_start_command</varname> and <varname>repmgrd_service_stop_command</varname>
|
||||
in <filename>repmgr.conf</filename>.
|
||||
diff --git a/repmgr-action-service.c b/repmgr-action-service.c
|
||||
index 74941be..2e29e30 100644
|
||||
--- a/repmgr-action-service.c
|
||||
+++ b/repmgr-action-service.c
|
||||
@@ -26,9 +26,6 @@
|
||||
#include "repmgr-client-global.h"
|
||||
#include "repmgr-action-service.h"
|
||||
|
||||
-#define REPMGR_SERVICE_STOP_START_WAIT 15
|
||||
-#define REPMGR_SERVICE_STATUS_START_HINT _("use \"repmgr service status\" to confirm that repmgrd was successfully started")
|
||||
-#define REPMGR_SERVICE_STATUS_STOP_HINT _("use \"repmgr service status\" to confirm that repmgrd was successfully stopped")
|
||||
|
||||
/*
|
||||
* Possibly also show:
|
||||
@@ -499,284 +496,6 @@ fetch_node_records(PGconn *conn, NodeInfoList *node_list)
|
||||
}
|
||||
|
||||
|
||||
-void
|
||||
-do_service_start(void)
|
||||
-{
|
||||
- PGconn *conn = NULL;
|
||||
- PQExpBufferData repmgrd_command;
|
||||
- PQExpBufferData output_buf;
|
||||
- bool success;
|
||||
-
|
||||
- if (config_file_options.repmgrd_service_start_command[0] == '\0')
|
||||
- {
|
||||
- log_error(_("\"repmgrd_service_start_command\" is not set"));
|
||||
- log_hint(_("set \"repmgrd_service_start_command\" in \"repmgr.conf\""));
|
||||
- exit(ERR_BAD_CONFIG);
|
||||
- }
|
||||
-
|
||||
- log_verbose(LOG_INFO, _("connecting to local node"));
|
||||
-
|
||||
- conn = establish_db_connection(config_file_options.conninfo, false);
|
||||
-
|
||||
- if (PQstatus(conn) != CONNECTION_OK)
|
||||
- {
|
||||
- /* TODO: if PostgreSQL is not available, have repmgrd loop and retry connection */
|
||||
- log_error(_("unable to connect to local node"));
|
||||
- log_detail(_("PostgreSQL must be running before \"repmgrd\" can be started"));
|
||||
- exit(ERR_DB_CONN);
|
||||
- }
|
||||
-
|
||||
- /*
|
||||
- * if local connection available, check if repmgr.so is installed, and
|
||||
- * whether repmgrd is running
|
||||
- */
|
||||
- check_shared_library(conn);
|
||||
-
|
||||
- if (is_repmgrd_running(conn) == true)
|
||||
- {
|
||||
- pid_t pid = UNKNOWN_PID;
|
||||
-
|
||||
- log_error(_("repmgrd appears to be running already"));
|
||||
-
|
||||
- pid = repmgrd_get_pid(conn);
|
||||
-
|
||||
- if (pid != UNKNOWN_PID)
|
||||
- log_detail(_("repmgrd PID is %i"), pid);
|
||||
- else
|
||||
- log_warning(_("unable to determine repmgrd PID"));
|
||||
-
|
||||
- PQfinish(conn);
|
||||
- exit(ERR_REPMGRD_SERVICE);
|
||||
- }
|
||||
-
|
||||
- PQfinish(conn);
|
||||
-
|
||||
-
|
||||
- initPQExpBuffer(&repmgrd_command);
|
||||
- appendPQExpBufferStr(&repmgrd_command,
|
||||
- config_file_options.repmgrd_service_start_command);
|
||||
-
|
||||
- if (runtime_options.dry_run == true)
|
||||
- {
|
||||
- log_info(_("prerequisites for starting repmgrd met"));
|
||||
- log_detail("following command would be executed:\n %s", repmgrd_command.data);
|
||||
- exit(SUCCESS);
|
||||
- }
|
||||
-
|
||||
- log_notice(_("executing: \"%s\""), repmgrd_command.data);
|
||||
-
|
||||
- initPQExpBuffer(&output_buf);
|
||||
-
|
||||
- success = local_command(repmgrd_command.data, &output_buf);
|
||||
- termPQExpBuffer(&repmgrd_command);
|
||||
-
|
||||
- if (success == false)
|
||||
- {
|
||||
- log_error(_("unable to start repmgrd"));
|
||||
- if (output_buf.data[0] != '\0')
|
||||
- log_detail("%s", output_buf.data);
|
||||
- termPQExpBuffer(&output_buf);
|
||||
- exit(ERR_REPMGRD_SERVICE);
|
||||
- }
|
||||
-
|
||||
- termPQExpBuffer(&output_buf);
|
||||
-
|
||||
- if (runtime_options.no_wait == true || runtime_options.wait == 0)
|
||||
- {
|
||||
- log_hint(REPMGR_SERVICE_STATUS_START_HINT);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- int i = 0;
|
||||
- int timeout = REPMGR_SERVICE_STOP_START_WAIT;
|
||||
-
|
||||
- if (runtime_options.wait_provided)
|
||||
- timeout = runtime_options.wait;
|
||||
-
|
||||
- conn = establish_db_connection(config_file_options.conninfo, false);
|
||||
-
|
||||
- if (PQstatus(conn) != CONNECTION_OK)
|
||||
- {
|
||||
- log_notice(_("unable to connect to local node"));
|
||||
- log_hint(REPMGR_SERVICE_STATUS_START_HINT);
|
||||
- exit(ERR_DB_CONN);
|
||||
- }
|
||||
-
|
||||
- for (;;)
|
||||
- {
|
||||
- if (is_repmgrd_running(conn) == true)
|
||||
- {
|
||||
- log_notice(_("repmgrd was successfully started"));
|
||||
- PQfinish(conn);
|
||||
- break;
|
||||
- }
|
||||
-
|
||||
- if (i == timeout)
|
||||
- {
|
||||
- PQfinish(conn);
|
||||
- log_error(_("repmgrd does not appear to have started after %i seconds"),
|
||||
- timeout);
|
||||
- log_hint(REPMGR_SERVICE_STATUS_START_HINT);
|
||||
- exit(ERR_REPMGRD_SERVICE);
|
||||
- }
|
||||
-
|
||||
- log_debug("sleeping 1 second; %i of %i attempts to determine if repmgrd is running",
|
||||
- i, runtime_options.wait);
|
||||
- sleep(1);
|
||||
- i++;
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-
|
||||
-void do_service_stop(void)
|
||||
-{
|
||||
- PGconn *conn = NULL;
|
||||
- PQExpBufferData repmgrd_command;
|
||||
- PQExpBufferData output_buf;
|
||||
- bool success;
|
||||
- bool have_db_connection = true;
|
||||
- pid_t pid = UNKNOWN_PID;
|
||||
-
|
||||
- if (config_file_options.repmgrd_service_stop_command[0] == '\0')
|
||||
- {
|
||||
- log_error(_("\"repmgrd_service_stop_command\" is not set"));
|
||||
- log_hint(_("set \"repmgrd_service_stop_command\" in \"repmgr.conf\""));
|
||||
- exit(ERR_BAD_CONFIG);
|
||||
- }
|
||||
-
|
||||
- /*
|
||||
- * if local connection available, check if repmgr.so is installed, and
|
||||
- * whether repmgrd is running
|
||||
- */
|
||||
- log_verbose(LOG_INFO, _("connecting to local node"));
|
||||
-
|
||||
- conn = establish_db_connection(config_file_options.conninfo, false);
|
||||
-
|
||||
- if (PQstatus(conn) != CONNECTION_OK)
|
||||
- {
|
||||
- /*
|
||||
- * a PostgreSQL connection is not required to stop repmgrd,
|
||||
- */
|
||||
- log_warning(_("unable to connect to local node"));
|
||||
- have_db_connection = false;
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- check_shared_library(conn);
|
||||
-
|
||||
- if (is_repmgrd_running(conn) == false)
|
||||
- {
|
||||
- log_error(_("repmgrd appears to be stopped already"));
|
||||
- PQfinish(conn);
|
||||
- exit(ERR_REPMGRD_SERVICE);
|
||||
- }
|
||||
-
|
||||
- /* Attempt to fetch the PID, in case we need it later */
|
||||
- pid = repmgrd_get_pid(conn);
|
||||
- log_debug("retrieved pid is %i", pid);
|
||||
- }
|
||||
-
|
||||
- PQfinish(conn);
|
||||
-
|
||||
- initPQExpBuffer(&repmgrd_command);
|
||||
-
|
||||
- appendPQExpBufferStr(&repmgrd_command,
|
||||
- config_file_options.repmgrd_service_stop_command);
|
||||
-
|
||||
- if (runtime_options.dry_run == true)
|
||||
- {
|
||||
- log_info(_("prerequisites for stopping repmgrd met"));
|
||||
- log_detail("following command would be executed:\n %s", repmgrd_command.data);
|
||||
- exit(SUCCESS);
|
||||
- }
|
||||
-
|
||||
- log_notice(_("executing: \"%s\""), repmgrd_command.data);
|
||||
-
|
||||
- initPQExpBuffer(&output_buf);
|
||||
-
|
||||
- success = local_command(repmgrd_command.data, &output_buf);
|
||||
- termPQExpBuffer(&repmgrd_command);
|
||||
-
|
||||
- if (success == false)
|
||||
- {
|
||||
- log_error(_("unable to stop repmgrd"));
|
||||
- if (output_buf.data[0] != '\0')
|
||||
- log_detail("%s", output_buf.data);
|
||||
- termPQExpBuffer(&output_buf);
|
||||
- exit(ERR_REPMGRD_SERVICE);
|
||||
- }
|
||||
-
|
||||
- termPQExpBuffer(&output_buf);
|
||||
-
|
||||
- if (runtime_options.no_wait == true || runtime_options.wait == 0)
|
||||
- {
|
||||
- if (have_db_connection == true)
|
||||
- log_hint(REPMGR_SERVICE_STATUS_STOP_HINT);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- int i = 0;
|
||||
- int timeout = REPMGR_SERVICE_STOP_START_WAIT;
|
||||
- /*
|
||||
- *
|
||||
- */
|
||||
- if (pid == UNKNOWN_PID)
|
||||
- {
|
||||
- /*
|
||||
- * XXX attempt to get pidfile from config
|
||||
- * and get contents
|
||||
- * ( see check_and_create_pid_file() )
|
||||
- * if PID still unknown, exit here
|
||||
- */
|
||||
- log_warning(_("unable to determine repmgrd PID"));
|
||||
-
|
||||
- if (have_db_connection == true)
|
||||
- log_hint(REPMGR_SERVICE_STATUS_STOP_HINT);
|
||||
-
|
||||
- exit(ERR_REPMGRD_SERVICE);
|
||||
- }
|
||||
-
|
||||
- if (runtime_options.wait_provided)
|
||||
- timeout = runtime_options.wait;
|
||||
-
|
||||
- for (;;)
|
||||
- {
|
||||
- if (kill(pid, 0) == -1)
|
||||
- {
|
||||
- if (errno == ESRCH)
|
||||
- {
|
||||
- log_notice(_("repmgrd was successfully stopped"));
|
||||
- exit(SUCCESS);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- log_error(_("unable to determine status of process with PID %i"), pid);
|
||||
- log_detail("%s", strerror(errno));
|
||||
- exit(ERR_REPMGRD_SERVICE);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
-
|
||||
- if (i == timeout)
|
||||
- {
|
||||
- log_error(_("repmgrd does not appear to have stopped after %i seconds"),
|
||||
- timeout);
|
||||
-
|
||||
- if (have_db_connection == true)
|
||||
- log_hint(REPMGR_SERVICE_STATUS_START_HINT);
|
||||
-
|
||||
- exit(ERR_REPMGRD_SERVICE);
|
||||
- }
|
||||
-
|
||||
- log_debug("sleeping 1 second; %i of %i attempts to determine if repmgrd with PID %i is running",
|
||||
- i, timeout, pid);
|
||||
- sleep(1);
|
||||
- i++;
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
-
|
||||
|
||||
void do_service_help(void)
|
||||
{
|
||||
@@ -786,8 +505,7 @@ void do_service_help(void)
|
||||
printf(_(" %s [OPTIONS] service status\n"), progname());
|
||||
printf(_(" %s [OPTIONS] service pause\n"), progname());
|
||||
printf(_(" %s [OPTIONS] service unpause\n"), progname());
|
||||
- printf(_(" %s [OPTIONS] service start\n"), progname());
|
||||
- printf(_(" %s [OPTIONS] service stop\n"), progname());
|
||||
+
|
||||
puts("");
|
||||
|
||||
printf(_("SERVICE STATUS\n"));
|
||||
@@ -799,24 +517,6 @@ void do_service_help(void)
|
||||
printf(_(" --verbose show text of database connection error messages\n"));
|
||||
puts("");
|
||||
|
||||
- printf(_("SERVICE START\n"));
|
||||
- puts("");
|
||||
- printf(_(" \"service start\" attempts to start repmgrd\n"));
|
||||
- puts("");
|
||||
- printf(_(" --dry-run check prerequisites but don't start repmgrd\n"));
|
||||
- printf(_(" -w/--wait wait for repmgrd to start (default: %i seconds)\n"), REPMGR_SERVICE_STOP_START_WAIT);
|
||||
- printf(_(" --no-wait don't wait for repmgrd to start\n"));
|
||||
- puts("");
|
||||
-
|
||||
- printf(_("SERVICE STOP\n"));
|
||||
- puts("");
|
||||
- printf(_(" \"service stop\" attempts to stop repmgrd\n"));
|
||||
- puts("");
|
||||
- printf(_(" --dry-run check prerequisites but don't stop repmgrd\n"));
|
||||
- printf(_(" -w/--wait wait for repmgrd to stop (default: %i seconds)\n"), REPMGR_SERVICE_STOP_START_WAIT);
|
||||
- printf(_(" --no-wait don't wait for repmgrd to stop\n"));
|
||||
- puts("");
|
||||
-
|
||||
printf(_("SERVICE PAUSE\n"));
|
||||
puts("");
|
||||
printf(_(" \"service pause\" instructs repmgrd on each node to pause failover detection\n"));
|
||||
diff --git a/repmgr-action-service.h b/repmgr-action-service.h
|
||||
index a62ce75..e22c059 100644
|
||||
--- a/repmgr-action-service.h
|
||||
+++ b/repmgr-action-service.h
|
||||
@@ -23,8 +23,6 @@
|
||||
extern void do_service_status(void);
|
||||
extern void do_service_pause(void);
|
||||
extern void do_service_unpause(void);
|
||||
-extern void do_service_start(void);
|
||||
-extern void do_service_stop(void);
|
||||
|
||||
extern void do_service_help(void);
|
||||
#endif
|
||||
diff --git a/repmgr-client.c b/repmgr-client.c
|
||||
index ee7315c..c0e6263 100644
|
||||
--- a/repmgr-client.c
|
||||
+++ b/repmgr-client.c
|
||||
@@ -36,8 +36,9 @@
|
||||
* SERVICE STATUS
|
||||
* SERVICE PAUSE
|
||||
* SERVICE UNPAUSE
|
||||
- * SERVICE START
|
||||
- * SERVICE STOP
|
||||
+ *
|
||||
+ * DAEMON START
|
||||
+ * DAEMON STOP
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -70,6 +71,7 @@
|
||||
#include "repmgr-action-node.h"
|
||||
#include "repmgr-action-cluster.h"
|
||||
#include "repmgr-action-service.h"
|
||||
+#include "repmgr-action-daemon.h"
|
||||
|
||||
#include <storage/fd.h> /* for PG_TEMP_FILE_PREFIX */
|
||||
|
||||
@@ -952,8 +954,7 @@ main(int argc, char **argv)
|
||||
else if (strcasecmp(repmgr_action, "CLEANUP") == 0)
|
||||
action = CLUSTER_CLEANUP;
|
||||
}
|
||||
- /* allow "daemon" as an alias for "service" for repmgr 4.x compatibility */
|
||||
- else if (strcasecmp(repmgr_command, "SERVICE") == 0 || strcasecmp(repmgr_command, "DAEMON") == 0)
|
||||
+ else if (strcasecmp(repmgr_command, "SERVICE") == 0)
|
||||
{
|
||||
if (help_option == true)
|
||||
{
|
||||
@@ -967,10 +968,28 @@ main(int argc, char **argv)
|
||||
action = SERVICE_PAUSE;
|
||||
else if (strcasecmp(repmgr_action, "UNPAUSE") == 0)
|
||||
action = SERVICE_UNPAUSE;
|
||||
- else if (strcasecmp(repmgr_action, "START") == 0)
|
||||
- action = SERVICE_START;
|
||||
+
|
||||
+ }
|
||||
+ else if (strcasecmp(repmgr_command, "DAEMON") == 0)
|
||||
+ {
|
||||
+ if (help_option == true)
|
||||
+ {
|
||||
+ do_daemon_help();
|
||||
+ exit(SUCCESS);
|
||||
+ }
|
||||
+
|
||||
+ if (strcasecmp(repmgr_action, "START") == 0)
|
||||
+ action = DAEMON_START;
|
||||
else if (strcasecmp(repmgr_action, "STOP") == 0)
|
||||
- action = SERVICE_STOP;
|
||||
+ action = DAEMON_STOP;
|
||||
+
|
||||
+ /* allow "daemon" as an alias for "service" for repmgr 4.x compatibility */
|
||||
+ if (strcasecmp(repmgr_action, "STATUS") == 0)
|
||||
+ action = SERVICE_STATUS;
|
||||
+ else if (strcasecmp(repmgr_action, "PAUSE") == 0)
|
||||
+ action = SERVICE_PAUSE;
|
||||
+ else if (strcasecmp(repmgr_action, "UNPAUSE") == 0)
|
||||
+ action = SERVICE_UNPAUSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1383,11 +1402,13 @@ main(int argc, char **argv)
|
||||
case SERVICE_UNPAUSE:
|
||||
do_service_unpause();
|
||||
break;
|
||||
- case SERVICE_START:
|
||||
- do_service_start();
|
||||
+
|
||||
+ /* DAEMON */
|
||||
+ case DAEMON_START:
|
||||
+ do_daemon_start();
|
||||
break;
|
||||
- case SERVICE_STOP:
|
||||
- do_service_stop();
|
||||
+ case DAEMON_STOP:
|
||||
+ do_daemon_stop();
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1755,8 +1776,8 @@ check_cli_parameters(const int action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
- case SERVICE_START:
|
||||
- case SERVICE_STOP:
|
||||
+ case DAEMON_START:
|
||||
+ case DAEMON_STOP:
|
||||
case STANDBY_FOLLOW:
|
||||
break;
|
||||
default:
|
||||
@@ -1769,8 +1790,8 @@ check_cli_parameters(const int action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
- case SERVICE_START:
|
||||
- case SERVICE_STOP:
|
||||
+ case DAEMON_START:
|
||||
+ case DAEMON_STOP:
|
||||
case NODE_REJOIN:
|
||||
break;
|
||||
default:
|
||||
@@ -1895,8 +1916,8 @@ check_cli_parameters(const int action)
|
||||
case NODE_SERVICE:
|
||||
case SERVICE_PAUSE:
|
||||
case SERVICE_UNPAUSE:
|
||||
- case SERVICE_START:
|
||||
- case SERVICE_STOP:
|
||||
+ case DAEMON_START:
|
||||
+ case DAEMON_STOP:
|
||||
break;
|
||||
default:
|
||||
item_list_append_format(&cli_warnings,
|
||||
@@ -2469,10 +2490,11 @@ action_name(const int action)
|
||||
return "SERVICE PAUSE";
|
||||
case SERVICE_UNPAUSE:
|
||||
return "SERVICE UNPAUSE";
|
||||
- case SERVICE_START:
|
||||
- return "SERVICE START";
|
||||
- case SERVICE_STOP:
|
||||
- return "SERVICE STOP";
|
||||
+
|
||||
+ case DAEMON_START:
|
||||
+ return "DAEMON START";
|
||||
+ case DAEMON_STOP:
|
||||
+ return "DAEMON STOP";
|
||||
}
|
||||
|
||||
return "UNKNOWN ACTION";
|
||||
@@ -2583,7 +2605,8 @@ do_help(void)
|
||||
printf(_(" %s [OPTIONS] node {status|check|rejoin|service}\n"), progname());
|
||||
printf(_(" %s [OPTIONS] cluster {show|event|matrix|crosscheck|cleanup}\n"), progname());
|
||||
printf(_(" %s [OPTIONS] witness {register|unregister}\n"), progname());
|
||||
- printf(_(" %s [OPTIONS] service {status|pause|unpause|start|stop}\n"), progname());
|
||||
+ printf(_(" %s [OPTIONS] service {status|pause|unpause}\n"), progname());
|
||||
+ printf(_(" %s [OPTIONS] daemon {start|stop}\n"), progname());
|
||||
|
||||
puts("");
|
||||
|
||||
diff --git a/repmgr-client.h b/repmgr-client.h
|
||||
index 679aa38..9620849 100644
|
||||
--- a/repmgr-client.h
|
||||
+++ b/repmgr-client.h
|
||||
@@ -49,8 +49,8 @@
|
||||
#define SERVICE_STATUS 23
|
||||
#define SERVICE_PAUSE 24
|
||||
#define SERVICE_UNPAUSE 25
|
||||
-#define SERVICE_START 26
|
||||
-#define SERVICE_STOP 27
|
||||
+#define DAEMON_START 26
|
||||
+#define DAEMON_STOP 27
|
||||
|
||||
/* command line options without short versions */
|
||||
#define OPT_HELP 1001
|
||||
Reference in New Issue
Block a user