summaryrefslogtreecommitdiff
path: root/src/ingestor.hpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan.goodliffe@octal.co.uk>2026-03-19 12:33:48 +0000
committerDan Goodliffe <dan.goodliffe@octal.co.uk>2026-03-19 12:33:48 +0000
commit8c6fecd356003309f8eebec30374344272ca6072 (patch)
tree023f79e07a3abd0829c91bfffd5d2a5657d8a225 /src/ingestor.hpp
parentee01cb7017e3895419544a0385f90f8eb0498680 (diff)
downloadwebstat-8c6fecd356003309f8eebec30374344272ca6072.tar.bz2
webstat-8c6fecd356003309f8eebec30374344272ca6072.tar.xz
webstat-8c6fecd356003309f8eebec30374344272ca6072.zip
Gracefully handle SIGTERM
Apache sends SIGTERM to the logger process to it shutdown. Honestly I thought it would just close stdin and I should have checked.
Diffstat (limited to 'src/ingestor.hpp')
-rw-r--r--src/ingestor.hpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ingestor.hpp b/src/ingestor.hpp
index 0bf2297..2ae2936 100644
--- a/src/ingestor.hpp
+++ b/src/ingestor.hpp
@@ -39,7 +39,7 @@ namespace WebStat {
Ingestor(const utsname &, IngestorSettings);
Ingestor(const utsname &, DB::ConnectionPoolPtr, IngestorSettings);
- virtual ~Ingestor() = default;
+ virtual ~Ingestor();
SPECIAL_MEMBERS_DELETE(Ingestor);
using ScanResult = decltype(scn::scan<std::string_view, std::string_view, uint64_t, std::string_view,
@@ -63,6 +63,7 @@ namespace WebStat {
IngestorSettings settings;
protected:
+ static Ingestor * currentIngestor;
DB::ConnectionPoolPtr dbpool;
size_t linesRead = 0;
@@ -71,6 +72,8 @@ namespace WebStat {
size_t linesParked = 0;
mutable std::flat_set<Crc32Value> existingEntities;
+ bool terminated = false;
+
struct Job {
using LastRunTime = std::chrono::system_clock::time_point;
using Impl = unsigned int (Ingestor::*)();
@@ -98,6 +101,9 @@ namespace WebStat {
void jobIngestParkedLine(const std::filesystem::directory_iterator &);
void jobIngestParkedLine(const std::filesystem::path &, uintmax_t size);
+ static void sigtermHandler(int);
+ void terminate(int);
+
using CurlOperations = std::map<CURL *, std::unique_ptr<CurlOperation>>;
uint32_t hostnameId;
CurlMultiPtr curl;