← back to Allnewsdaily
Live static-mode via sentinel file (no prod env/restart) instead of LIVE_STATIC env
9a1fdc00a99fea036a9ca641bdbc55e4139d977f · 2026-09-09 14:56:00 -0700 · Steve
server.js doesn't load dotenv, so a LIVE_STATIC env would need a pm2 --update-env that risks
dropping PORT=9962 and breaking the nginx proxy. Safer: static-live activates when
data/live-static.flag exists (checked each tick, no restart). The Mac2 pusher drops the flag on
prod after pushing live-status.json, so go-live needs only: deploy + load the Mac2 push job.
env LIVE_STATIC=1 still works as an override. Verified: flag present → checker disabled; removed → restored.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PV1DXsyryWT3rLttpPXd4u
Files touched
M .gitignoreM scripts/push-live-status.shM server.js
Diff
commit 9a1fdc00a99fea036a9ca641bdbc55e4139d977f
Author: Steve <steve@designerwallcoverings.com>
Date: Wed Sep 9 14:56:00 2026 -0700
Live static-mode via sentinel file (no prod env/restart) instead of LIVE_STATIC env
server.js doesn't load dotenv, so a LIVE_STATIC env would need a pm2 --update-env that risks
dropping PORT=9962 and breaking the nginx proxy. Safer: static-live activates when
data/live-static.flag exists (checked each tick, no restart). The Mac2 pusher drops the flag on
prod after pushing live-status.json, so go-live needs only: deploy + load the Mac2 push job.
env LIVE_STATIC=1 still works as an override. Verified: flag present → checker disabled; removed → restored.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PV1DXsyryWT3rLttpPXd4u
---
.gitignore | 1 +
scripts/push-live-status.sh | 6 +++++-
server.js | 16 ++++++++++------
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
index 4f9b69c..9981df4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,4 @@ data/live-status.json
data/paraphrase-cache.json
data/wire.json
+data/live-static.flag
diff --git a/scripts/push-live-status.sh b/scripts/push-live-status.sh
index 9316ade..80aea83 100755
--- a/scripts/push-live-status.sh
+++ b/scripts/push-live-status.sh
@@ -21,4 +21,8 @@ done
"$NODE" -e "const s=require('./data/live-status.json'); if(typeof s!=='object'||Array.isArray(s)){process.exit(2)}" || { echo "[push-live] live-status.json invalid, not pushing"; exit 2; }
rsync -az -e "ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new" data/live-status.json "$PROD:$REMOTE"
-echo "[push-live] pushed $(date -u +%FT%TZ) → $PROD:$REMOTE"
+# Drop the sentinel so prod enters static-live mode (its own checker self-disables — no prod env
+# change, no restart). Idempotent; survives deploys because data/ is excluded from rsync --delete.
+ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new "$PROD" \
+ "touch /root/Projects/allnewsdaily/data/live-static.flag" || true
+echo "[push-live] pushed $(date -u +%FT%TZ) → $PROD:$REMOTE (+ static flag)"
diff --git a/server.js b/server.js
index 15ec081..395ba96 100644
--- a/server.js
+++ b/server.js
@@ -8,9 +8,12 @@ const { rebuild, getWire, meta, loadStaticWire } = require('./lib/aggregate');
// external pusher (scripts/build-wire.js on a machine that HAS Ollama). Never fetches/rewrites here.
const WIRE_STATIC = process.env.WIRE_STATIC === '1';
// On prod (datacenter IP) YouTube serves a consent/bot wall, so the live checker finds 0 live.
-// Set LIVE_STATIC=1 to DISABLE the local checker and instead serve data/live-status.json pushed
-// from a residential-IP machine (Mac2) via scripts/push-live-status.sh — mirrors WIRE_STATIC.
-const LIVE_STATIC = process.env.LIVE_STATIC === '1';
+// "Static-live" mode DISABLES the local checker and serves data/live-status.json pushed from a
+// residential-IP machine (Mac2) via scripts/push-live-status.sh. Enabled by env LIVE_STATIC=1 OR
+// the presence of data/live-static.flag (dropped on prod by the pusher) — the flag form needs NO
+// prod env change and NO restart (avoids a --update-env that could drop PORT), and self-activates.
+const LIVE_STATIC_FLAG = path.join(__dirname, 'data', 'live-static.flag');
+function liveStatic() { return process.env.LIVE_STATIC === '1' || fs.existsSync(LIVE_STATIC_FLAG); }
const app = express();
const PORT = process.env.PORT || 9788;
@@ -449,12 +452,13 @@ const WIRE_REFRESH_MS = parseInt(process.env.WIRE_REFRESH_MS || String(REFRESH_M
app.listen(PORT, () => {
console.log(`allnewsdaily listening on http://0.0.0.0:${PORT}`);
console.log(`outlets loaded: ${loadOutlets().length}`);
- if (LIVE_STATIC) {
- console.log('[live] static mode — serving pushed live-status.json (local checker disabled)');
+ if (liveStatic()) {
+ console.log('[live] static mode at boot — serving pushed live-status.json (local checker disabled)');
} else {
runChecker();
- setInterval(runChecker, POLL_INTERVAL_MS);
}
+ // Re-check each tick so the flag can enable static mode WITHOUT a restart; skip checking when static.
+ setInterval(() => { if (!liveStatic()) runChecker(); }, POLL_INTERVAL_MS);
if (WIRE_STATIC) {
// Prod: serve the pre-built snapshot; re-read the file as the pusher refreshes it.
const ok = loadStaticWire();
← 7620db7 Live feature: LIVE_STATIC mode + Mac2 push (consent-cookie f
·
back to Allnewsdaily
·
allnewsdaily: daily YouTube Short pipeline (headlines→vertic 9eb9cfa →