← back to Wallco Ai
feat(mockup-queue): auto-refresh designs.json + hot-reload server after batch
ccbd1fb705118ffdd15c65fca60d6b8df4b8f3c5 · 2026-05-29 08:01:10 -0700 · Steve Abrams
Without this, the customer-facing chip count on /designs stays stale until a
manual refresh_designs_snapshot.py + /admin/reload-designs. Fires only when
ok>0 and --no-auto-refresh not passed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files touched
M scripts/queue-room-mockups-for-etsy-bucket.js
Diff
commit ccbd1fb705118ffdd15c65fca60d6b8df4b8f3c5
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Fri May 29 08:01:10 2026 -0700
feat(mockup-queue): auto-refresh designs.json + hot-reload server after batch
Without this, the customer-facing chip count on /designs stays stale until a
manual refresh_designs_snapshot.py + /admin/reload-designs. Fires only when
ok>0 and --no-auto-refresh not passed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
scripts/queue-room-mockups-for-etsy-bucket.js | 29 +++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/scripts/queue-room-mockups-for-etsy-bucket.js b/scripts/queue-room-mockups-for-etsy-bucket.js
index 6c9b46a..4ee5e85 100644
--- a/scripts/queue-room-mockups-for-etsy-bucket.js
+++ b/scripts/queue-room-mockups-for-etsy-bucket.js
@@ -101,5 +101,34 @@ async function main() {
if (i < cap - 1) await new Promise(r => setTimeout(r, opt.rateLimitSec * 1000));
}
console.log(`\n${ok} ok · ${err} errors · spent ~$${(ok * opt.costPerCall).toFixed(2)}`);
+
+ // Auto-refresh — without this, the customer-facing chip count on /designs
+ // stays stale (in-memory DESIGNS array reads from data/designs.json, which
+ // is rebuilt only by refresh_designs_snapshot.py + reload via
+ // /admin/reload-designs). Steve 2026-05-29: "auto-refresh after batch".
+ // Skipped when --no-auto-refresh OR when 0 successful renders (nothing to
+ // surface anyway).
+ if (ok > 0 && !HAS('--no-auto-refresh')) {
+ console.log('\n══ auto-refresh: rebuild designs.json + hot-reload server ══');
+ try {
+ const r = require('child_process').spawnSync(
+ 'python3', [require('path').join(__dirname, 'refresh_designs_snapshot.py')],
+ { stdio: 'inherit', timeout: 120000 });
+ if (r.status !== 0) { console.log(` ⚠ snapshot rebuild exit=${r.status} — chip count may stay stale`); return; }
+ // Hot-reload the in-memory DESIGNS — no pm2 restart needed
+ const reload = await new Promise((resolve) => {
+ const u = new URL(opt.apiBase + '/admin/reload-designs');
+ const req = http.request({ method: 'POST', hostname: u.hostname, port: u.port, path: u.pathname,
+ auth: 'admin:DWSecure2024!', timeout: 15000 }, res => {
+ let data = ''; res.on('data', c => data += c);
+ res.on('end', () => resolve({ status: res.statusCode, body: data.slice(0, 200) }));
+ });
+ req.on('error', e => resolve({ status: 0, body: e.message }));
+ req.on('timeout', () => req.destroy(new Error('timeout')));
+ req.end();
+ });
+ console.log(` reload: HTTP ${reload.status} ${reload.body}`);
+ } catch (e) { console.log(` ⚠ auto-refresh failed: ${e.message}`); }
+ }
}
main().catch(e => { console.error('fatal:', e.message); process.exit(1); });
← 13587cd fix(by-id-image): query all_designs not spoon_all_designs in
·
back to Wallco Ai
·
chore(gitignore): ignore timestamped *.bak.* runtime backups 52f07a5 →