···44import { logger } from './lib/observability';
55import { mkdirSync, existsSync } from 'fs';
66import { backfillCache } from './lib/backfill';
77-import { startDomainCacheCleanup, stopDomainCacheCleanup } from './lib/db';
77+import { startDomainCacheCleanup, stopDomainCacheCleanup, setCacheOnlyMode } from './lib/db';
8899const PORT = process.env.PORT ? parseInt(process.env.PORT) : 3001;
1010const CACHE_DIR = process.env.CACHE_DIR || './cache/sites';
···1313const args = process.argv.slice(2);
1414const hasBackfillFlag = args.includes('--backfill');
1515const backfillOnStartup = hasBackfillFlag || process.env.BACKFILL_ON_STARTUP === 'true';
1616+1717+// Cache-only mode: service will only cache files locally, no DB writes
1818+const hasCacheOnlyFlag = args.includes('--cache-only');
1919+export const CACHE_ONLY_MODE = hasCacheOnlyFlag || process.env.CACHE_ONLY_MODE === 'true';
2020+2121+// Configure cache-only mode in database module
2222+if (CACHE_ONLY_MODE) {
2323+ setCacheOnlyMode(true);
2424+}
16251726// Ensure cache directory exists
1827if (!existsSync(CACHE_DIR)) {
···6574Health: http://localhost:${PORT}/health
6675Cache: ${CACHE_DIR}
6776Firehose: Connected to Firehose
7777+Cache-Only: ${CACHE_ONLY_MODE ? 'ENABLED (no DB writes)' : 'DISABLED'}
6878`);
69797080// Graceful shutdown
+16
hosting-service/src/lib/db.ts
···11import postgres from 'postgres';
22import { createHash } from 'crypto';
3344+// Global cache-only mode flag (set by index.ts)
55+let cacheOnlyMode = false;
66+77+export function setCacheOnlyMode(enabled: boolean) {
88+ cacheOnlyMode = enabled;
99+ if (enabled) {
1010+ console.log('[DB] Cache-only mode enabled - database writes will be skipped');
1111+ }
1212+}
1313+414const sql = postgres(
515 process.env.DATABASE_URL || 'postgres://postgres:postgres@localhost:5432/wisp',
616 {
···130140}
131141132142export async function upsertSite(did: string, rkey: string, displayName?: string) {
143143+ // Skip database writes in cache-only mode
144144+ if (cacheOnlyMode) {
145145+ console.log('[DB] Skipping upsertSite (cache-only mode)', { did, rkey });
146146+ return;
147147+ }
148148+133149 try {
134150 // Only set display_name if provided (not undefined/null/empty)
135151 const cleanDisplayName = displayName && displayName.trim() ? displayName.trim() : null;
+2
hosting-service/src/lib/firehose.ts
···197197 )
198198199199 // Acquire distributed lock only for database write to prevent duplicate writes
200200+ // Note: upsertSite will check cache-only mode internally and skip if needed
200201 const lockKey = `db:upsert:${did}:${site}`
201202 const lockAcquired = await tryAcquireLock(lockKey)
202203···214215215216 try {
216217 // Upsert site to database (only one instance does this)
218218+ // In cache-only mode, this will be a no-op
217219 await upsertSite(did, site, fsRecord.site)
218220 this.log(
219221 'Successfully processed create/update (cached + DB updated)',