Merge MVP startup defaults with memory-db mode + tests

This commit is contained in:
2026-03-01 19:24:59 -05:00
parent 5e27459325
commit e4901f027c
12 changed files with 1131 additions and 89 deletions

View File

@@ -2,14 +2,20 @@ import 'dotenv/config';
import pg from 'pg';
const { Pool } = pg;
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const isMemoryDb = !process.env.DATABASE_URL || process.env.DATABASE_URL.startsWith('memory://');
const pool = isMemoryDb ? null : new Pool({ connectionString: process.env.DATABASE_URL });
const tickMs = parseInt(process.env.WORKER_TICK_MS || '10000', 10);
const runOnce = process.env.WORKER_RUN_ONCE === '1';
// Placeholder worker loop
async function main() {
// eslint-disable-next-line no-console
console.log('Mastermind worker started');
if (pool) {
await pool.query('select 1');
}
console.log(`Mastermind worker started (${isMemoryDb ? 'memory' : 'postgres'})`);
while (true) {
await new Promise((r) => setTimeout(r, 10_000));
await new Promise((r) => setTimeout(r, tickMs));
if (runOnce) break;
// future: ingest inbox, OCR docs, classify
}
}