Skip to content

Commit

Permalink
Merge pull request ceph#46124 from SMIL-Infra/reopen_cluster_logs
Browse files Browse the repository at this point in the history
mon/LogMonitor: reopen log files on SIGHUP
  • Loading branch information
vumrao authored May 23, 2022
2 parents 09b3210 + ee80f9f commit cd08198
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/mon/LogMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
5 changes: 5 additions & 0 deletions src/mon/LogMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef CEPH_LOGMONITOR_H
#define CEPH_LOGMONITOR_H

#include <atomic>
#include <map>
#include <set>

Expand Down Expand Up @@ -51,6 +52,7 @@ class LogMonitor : public PaxosService,
std::map<std::string, int> channel_fds;

fmt::memory_buffer file_log_buffer;
std::atomic<bool> log_rotated = false;

struct log_channel_info {

Expand Down Expand Up @@ -167,6 +169,9 @@ class LogMonitor : public PaxosService,
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();
Expand Down
1 change: 1 addition & 0 deletions src/mon/Monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit cd08198

Please sign in to comment.