Feat: Add System Control (Standby Mode) and Resource Monitor
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user