summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mon/LogMonitor.cc4
-rw-r--r--src/mon/LogMonitor.h5
-rw-r--r--src/mon/Monitor.cc1
3 files changed, 10 insertions, 0 deletions
diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc
index c196e8429fb..80e069d593a 100644
--- a/src/mon/LogMonitor.cc
+++ b/src/mon/LogMonitor.cc
@@ -387,6 +387,10 @@ void LogMonitor::log_external(const LogEntry& le)
}
if (g_conf()->mon_cluster_log_to_file) {
+ if (this->log_rotated.exchange(false)) {
+ this->log_external_close_fds();
+ }
+
auto p = channel_fds.find(channel);
int fd;
if (p == channel_fds.end()) {
diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h
index 715f380af6a..01909264ae3 100644
--- a/src/mon/LogMonitor.h
+++ b/src/mon/LogMonitor.h
@@ -15,6 +15,7 @@
#ifndef CEPH_LOGMONITOR_H
#define CEPH_LOGMONITOR_H
+#include <atomic>
#include <map>
#include <set>
@@ -51,6 +52,7 @@ private:
std::map<std::string, int> channel_fds;
fmt::memory_buffer file_log_buffer;
+ std::atomic<bool> log_rotated = false;
struct log_channel_info {
@@ -167,6 +169,9 @@ private:
void check_subs();
void check_sub(Subscription *s);
+ void reopen_logs() {
+ this->log_rotated.store(true);
+ }
void log_external_close_fds();
void log_external(const LogEntry& le);
void log_external_backlog();
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index 2d6e7cf4572..9cad33a9484 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -501,6 +501,7 @@ void Monitor::handle_signal(int signum)
derr << "*** Got Signal " << sig_str(signum) << " ***" << dendl;
if (signum == SIGHUP) {
sighup_handler(signum);
+ logmon()->reopen_logs();
} else {
ceph_assert(signum == SIGINT || signum == SIGTERM);
shutdown();