Keep HTTP responsive during confluence replay.
Boot replay was a tight CPU loop that wedged the Unraid backend, so login hit the 8s client timeout. Yield every few as-of dates, shorten the boot ledger fill, and make /health a cheap liveness check.
This commit is contained in:
@@ -301,7 +301,12 @@ export async function runConfluenceReplay(
|
||||
const weeklyFull = await provider.resolveAsOf(symbol, '1wk', '9999-12-31');
|
||||
const benchFull = await provider.resolveAsOf(BENCHMARK_SYMBOL, '1d', '9999-12-31');
|
||||
|
||||
let asOfN = 0;
|
||||
for (const asOf of slice) {
|
||||
asOfN += 1;
|
||||
if (asOfN % 4 === 0) {
|
||||
await new Promise<void>((r) => setImmediate(r));
|
||||
}
|
||||
const dailyCut = daily.candles.filter((c) => (c.ts ?? '').slice(0, 10) <= asOf);
|
||||
const weeklyCut = weeklyFull.candles.filter((c) => (c.ts ?? '').slice(0, 10) <= asOf);
|
||||
const benchCut = benchFull.candles.filter((c) => (c.ts ?? '').slice(0, 10) <= asOf);
|
||||
@@ -391,6 +396,7 @@ export async function fillLearningLedger(
|
||||
complete: batch.complete,
|
||||
};
|
||||
if (batch.evaluationsStored === 0) break;
|
||||
await new Promise<void>((r) => setImmediate(r));
|
||||
}
|
||||
return { ...last, ledger: await learningLedgerStatus(db, cache) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user