Feat: Add System Control (Standby Mode) and Resource Monitor

This commit is contained in:
cawcenter
2025-12-14 19:50:05 -05:00
parent f7997cdd88
commit 88d3157cd9
8 changed files with 274 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
import { system } from '@/lib/system/SystemController';
interface BatchConfig {
batchSize: number; // How many items to grab at once (e.g. 100)
concurrency: number; // How many to process in parallel (e.g. 5)
@@ -17,6 +19,18 @@ export class BatchProcessor {
const chunk = items.slice(i, i + this.config.batchSize);
console.log(`Processing Batch ${(i / this.config.batchSize) + 1}...`);
// Check System State (Standby Mode)
if (!system.isActive()) {
console.log('[God Mode] System in STANDBY. Pausing Batch Processor...');
// Wait until active again (check every 2s)
while (!system.isActive()) {
await new Promise(r => setTimeout(r, 2000));
}
console.log('[God Mode] System RESUMED.');
}
// Within each chunk, limit concurrency
// Within each chunk, limit concurrency
const chunkResults = await this.runWithConcurrency(chunk, workerFunction);
results.push(...chunkResults);