[object Object]

← back to Rentv 826 Tracker

single-source log mode: read+filter shared rentv.access.log, no nginx change needed

5d17a72d5ec55d0b2004f198e85ec967354edd26 · 2026-08-10 12:12:38 -0700 · steve

Files touched

Diff

commit 5d17a72d5ec55d0b2004f198e85ec967354edd26
Author: steve <steve@designerwallcoverings.com>
Date:   Mon Aug 10 12:12:38 2026 -0700

    single-source log mode: read+filter shared rentv.access.log, no nginx change needed
---
 .env.example | 7 ++++---
 README.md    | 9 ++++++---
 tracker.js   | 7 +++++++
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/.env.example b/.env.example
index f4ef816..31dbb07 100644
--- a/.env.example
+++ b/.env.example
@@ -1,8 +1,9 @@
 # Per-client DB (rentv_826) — least-privilege role, loopback scram-sha-256
 DATABASE_URL=postgres://rentv_826:CHANGEME@127.0.0.1:5432/rentv_826
-# nginx log the /826/ location writes to (live tail source)
-LIVE_LOG=/var/log/nginx/rentv-826.access.log
-# historical log to backfill /826/ hits from, one time (pre-split)
+# nginx log to read (the tracker filters /826/ authed lines out of it). Single-source
+# mode: point LIVE_LOG and BACKFILL_LOG at the same file — the first offset-0 pass
+# backfills history, then it tails the delta. No nginx config change required.
+LIVE_LOG=/var/log/nginx/rentv.access.log
 BACKFILL_LOG=/var/log/nginx/rentv.access.log
 # which client (row in clients table) this tracker attributes time to
 CLIENT_SLUG=boomer
diff --git a/README.md b/README.md
index 0f73d8e..efb8144 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,9 @@ node report.js [client]    # time-on-server report
 Deployed on Kamatera under pm2 as `rentv-826-tracker`.
 
 ## nginx
-The `location ^~ /826/` block writes its own `access_log /var/log/nginx/rentv-826.access.log`
-so live tailing is clean; historical `/826/` hits are backfilled once from the
-server-level `rentv.access.log`.
+**No nginx config change is required.** The tracker reads the existing server-level
+`rentv.access.log` and filters `/826/` authenticated lines itself. In single-source
+mode (`LIVE_LOG == BACKFILL_LOG`) the first offset-0 pass backfills all history, then it
+tails the delta (offset + inode tracked in `ingest_state`, so it survives restarts and
+log rotation). A dedicated `access_log` in the `/826/` location is an optional future
+optimization, not a dependency.
diff --git a/tracker.js b/tracker.js
index 4c11b3a..a16c781 100644
--- a/tracker.js
+++ b/tracker.js
@@ -82,6 +82,13 @@ async function processRange(file, start, end) {
 
 // --- backfill -----------------------------------------------------------
 async function backfill() {
+  // Single-source mode: if the backfill log IS the live log, the offset-tracked live
+  // tail reads it from byte 0 on first run — that initial pass IS the backfill. Running
+  // a separate backfill here would double-count. So skip it.
+  if (!BACKFILL_LOG || BACKFILL_LOG === LIVE_LOG) {
+    log('single-source mode: first live-tail pass from offset 0 serves as backfill');
+    return;
+  }
   const marker = `BACKFILL:${BACKFILL_LOG}`;
   const done = await getState(marker);
   if (done) { log('backfill already done for', BACKFILL_LOG); return; }

← ad03d7c rentv-826-tracker: server-side time-on-server tracker for /8  ·  back to Rentv 826 Tracker  ·  feat: static /826/stats.html dashboard regenerated by the tr cd97708 →