[object Object]

← back to Wallco Ai

Add nightly TIF backfill cron wrapper (cron-build-tifs.sh)

bce674cbe4db3993a82554704d4fde434ac9d464 · 2026-06-02 09:03:28 -0700 · Steve Abrams

flock-guarded, disk-guarded, log-rotating wrapper around
pilot-build-tifs.py --all so newly-published designs get TIFs nightly
(idempotent — skips existing). Shipped via deploy [2d]. Crontab install
line in the script header.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit bce674cbe4db3993a82554704d4fde434ac9d464
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Jun 2 09:03:28 2026 -0700

    Add nightly TIF backfill cron wrapper (cron-build-tifs.sh)
    
    flock-guarded, disk-guarded, log-rotating wrapper around
    pilot-build-tifs.py --all so newly-published designs get TIFs nightly
    (idempotent — skips existing). Shipped via deploy [2d]. Crontab install
    line in the script header.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 deploy-kamatera.sh         |  2 +-
 scripts/cron-build-tifs.sh | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/deploy-kamatera.sh b/deploy-kamatera.sh
index b1c4916..79a3816 100755
--- a/deploy-kamatera.sh
+++ b/deploy-kamatera.sh
@@ -106,7 +106,7 @@ rsync -az "$LOCAL_DIR/scripts/refresh_designs_snapshot.py" \
 #     for those features to work. List grows narrowly as endpoints add deps;
 #     don't unbox scripts/ wholesale.
 echo "[2d/6] ship runtime-endpoint scripts..."
-for script in scripts/seam-defect-boxes.py scripts/mint-shopify-download-token.js scripts/generate_designs.js scripts/generator_tick.js scripts/seam-heal-feather.py scripts/quantize-no-ghost.py scripts/recolor-tif.py scripts/tif-to-web.py scripts/pilot-build-tifs.py; do
+for script in scripts/seam-defect-boxes.py scripts/mint-shopify-download-token.js scripts/generate_designs.js scripts/generator_tick.js scripts/seam-heal-feather.py scripts/quantize-no-ghost.py scripts/recolor-tif.py scripts/tif-to-web.py scripts/pilot-build-tifs.py scripts/cron-build-tifs.sh; do
   if [ -f "$LOCAL_DIR/$script" ]; then
     rsync -az "$LOCAL_DIR/$script" "$REMOTE:$REMOTE_DIR/$script" && echo "  $script shipped"
   fi
diff --git a/scripts/cron-build-tifs.sh b/scripts/cron-build-tifs.sh
new file mode 100755
index 0000000..af7a5b0
--- /dev/null
+++ b/scripts/cron-build-tifs.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+# Nightly TIF backfill for wallco.ai (runs on prod / Kamatera via crontab).
+#
+# Builds a full-size TIF for every PUBLISHED design that doesn't have one yet,
+# so the /designs/hires/:id mural preview + the full-res colorway recolor stay
+# populated as new designs publish. pilot-build-tifs.py --all skips existing
+# TIFs, so this is cheap on a steady state (only NEW designs get built).
+#
+# - flock-guarded so two runs never overlap.
+# - --min-free-gb 15 disk guard (aborts before a build if disk runs low).
+# - logs to logs/tif-cron.log (rotated when > 5 MB; logs/ is rsync-excluded so
+#   the deploy never clobbers it).
+#
+# Install (idempotent) on prod:
+#   ( crontab -l 2>/dev/null | grep -v 'cron-build-tifs.sh'; \
+#     echo '30 3 * * * /root/public-projects/wallco-ai/scripts/cron-build-tifs.sh' ) | crontab -
+set -euo pipefail
+cd "$(dirname "$0")/.."
+mkdir -p logs
+LOG="logs/tif-cron.log"
+
+# rotate if big
+if [ -f "$LOG" ] && [ "$(wc -c < "$LOG")" -gt 5000000 ]; then
+  tail -c 1000000 "$LOG" > "$LOG.tmp" && mv "$LOG.tmp" "$LOG"
+fi
+
+exec 9> /tmp/wallco-tif-cron.lock
+if ! flock -n 9; then
+  echo "$(date -Is) another tif-cron run in progress — skipping" >> "$LOG"
+  exit 0
+fi
+
+echo "=== $(date -Is) wallco-tif nightly backfill start ===" >> "$LOG"
+python3 scripts/pilot-build-tifs.py --all --min-free-gb 15 --progress-every 500 >> "$LOG" 2>&1 || \
+  echo "$(date -Is) builder exited non-zero (disk guard or partial failures — see above)" >> "$LOG"
+echo "=== $(date -Is) wallco-tif nightly backfill done ===" >> "$LOG"

← 6c66773 color-dots: bind dot strips + Save toolbar only to VISIBLE i  ·  back to Wallco Ai  ·  cron-build-tifs.sh: only alarm on disk-guard abort (rc=2), n ecbba0f →