Merge MVP startup defaults with memory-db mode + tests
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user