"daemon stop": be careful with hints about "daemon status"

If PostgreSQL is not running, "repmgr daemon status" can't be executed.
This commit is contained in:
Ian Barwick
2019-01-30 14:49:43 +09:00
parent d7420d7274
commit d4ee4cc14c

View File

@@ -524,6 +524,7 @@ void do_daemon_stop(void)
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')
@@ -547,6 +548,7 @@ void do_daemon_stop(void)
* a PostgreSQL connection is not required to stop repmgrd,
*/
log_warning(_("unable to connect to local node"));
have_db_connection = false;
}
else
{
@@ -598,6 +600,7 @@ void do_daemon_stop(void)
if (runtime_options.no_wait == true || runtime_options.wait == 0)
{
if (have_db_connection == true)
log_hint(REPMGR_DAEMON_STATUS_STOP_HINT);
}
else
@@ -616,7 +619,10 @@ void do_daemon_stop(void)
* if PID still unknown, exit here
*/
log_warning(_("unable to determine repmgrd PID"));
if (have_db_connection == true)
log_hint(REPMGR_DAEMON_STATUS_STOP_HINT);
exit(ERR_REPMGRD_SERVICE);
}
@@ -645,7 +651,10 @@ void do_daemon_stop(void)
{
log_error(_("repmgrd does not appear to have stopped after %i seconds"),
timeout);
if (have_db_connection == true)
log_hint(REPMGR_DAEMON_STATUS_START_HINT);
exit(ERR_REPMGRD_SERVICE);
}