From 30a9d45f5322a63c2adf1de7a248ba3a9a0c3903 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 20 Dec 2025 15:16:25 +0000 Subject: Add job for puring old access log entries from the database --- src/ingestor.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/ingestor.hpp') diff --git a/src/ingestor.hpp b/src/ingestor.hpp index 3e25938..a19c8ec 100644 --- a/src/ingestor.hpp +++ b/src/ingestor.hpp @@ -17,6 +17,7 @@ namespace WebStat { using namespace std::chrono_literals; struct IngestorSettings : Settings { + // NOLINTBEGIN(readability-magic-numbers) std::string dbConnStr = "dbname=webstat user=webstat"; std::string userAgentAPI = "https://useragentstring.com"; std::filesystem::path fallbackDir = "/var/log/webstat"; @@ -24,6 +25,12 @@ namespace WebStat { unsigned int dbKeep = 2; int idleJobsAfter = duration_cast(1min).count(); minutes freqIngestParkedLines = 30min; + minutes freqPurgeOldLogs = 6h; + unsigned int purgeDaysToKeep = 61; // ~2 months + unsigned int purgeDeleteMax = 10'000; + minutes purgeDeleteMaxTime = 5min; + seconds purgeDeletePause = 3s; + // NOLINTEND(readability-magic-numbers) }; class Ingestor { @@ -48,6 +55,7 @@ namespace WebStat { void runJobsIdle(); void jobIngestParkedLines(); + unsigned int jobPurgeOldLogs(); template void storeLogLine(DB::Connection *, const std::tuple &) const; @@ -64,6 +72,7 @@ namespace WebStat { using JobLastRunTime = std::chrono::system_clock::time_point; JobLastRunTime lastRunIngestParkedLines; + JobLastRunTime lastRunPurgeOldLogs; private: static constexpr size_t MAX_NEW_ENTITIES = 6; -- cgit v1.2.3