From fea7eec14324f42cbba6d26066cff150d5fe0a7f Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Fri, 20 Feb 2026 23:18:04 +1300 Subject: [PATCH] Add Runner hooks for -k rotate event --- src/base/RunnersRegistry.h | 10 ++++++++++ src/main.cc | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/base/RunnersRegistry.h b/src/base/RunnersRegistry.h index 93a2294879b..52677fc997e 100644 --- a/src/base/RunnersRegistry.h +++ b/src/base/RunnersRegistry.h @@ -70,6 +70,16 @@ class RegisteredRunner /// Meant for adjusting the module state based on configuration changes. virtual void syncConfig() {} + /* Log Rotation events */ + + /// Called after receiving a log rotate request. + /// Meant for modules that manage log files to rename/rotate them. + virtual void rotateLogs() {} + + /// Called after rotating log files. + /// Meant for modules that need to (re-)attach to log files after rotation. + virtual void finishLogRotate() {} + /* Shutdown events */ /// Called after receiving a shutdown request and before stopping the main diff --git a/src/main.cc b/src/main.cc index c9ad17f905d..2bb05cfc580 100644 --- a/src/main.cc +++ b/src/main.cc @@ -944,6 +944,8 @@ mainRotate(void) if (AvoidSignalAction("log rotation", do_rotate)) return; + RunRegisteredHere(RegisteredRunner::rotateLogs); + icmpEngine.Close(); redirectShutdown(); #if USE_AUTH @@ -959,6 +961,9 @@ mainRotate(void) #if ICAP_CLIENT icapLogRotate(); /*icap.log*/ #endif + + RunRegisteredHere(RegisteredRunner::finishLogRotate); + icmpEngine.Open(); redirectInit(); #if USE_AUTH