diff --git a/email-worker-nodejs/src/worker/unified-worker.ts b/email-worker-nodejs/src/worker/unified-worker.ts index 8f4dad6..ea50df6 100644 --- a/email-worker-nodejs/src/worker/unified-worker.ts +++ b/email-worker-nodejs/src/worker/unified-worker.ts @@ -23,6 +23,7 @@ export class UnifiedWorker { private pollers: DomainPoller[] = []; private processor: MessageProcessor; private sqs: SQSHandler; + private statusInterval: NodeJS.Timeout | null = null; constructor( private domains: string[], @@ -78,10 +79,16 @@ export class UnifiedWorker { this.pollers.map((p) => p.stats.domain).join(', '), 'SUCCESS', ); + + // Starte den 5-Minuten-Status-Report + this.statusInterval = setInterval(() => { + this.printStatus(); + }, 5 * 60 * 1000); } async stop(): Promise { log('๐Ÿ›‘ Stopping all domain pollers...'); + if (this.statusInterval) clearInterval(this.statusInterval); // <-- Neue Zeile await Promise.all(this.pollers.map((p) => p.stop())); log('โœ… All pollers stopped.'); } @@ -103,4 +110,25 @@ export class UnifiedWorker { return { totalProcessed, totalErrors, domains }; } + + private printStatus(): void { + const stats = this.getStats(); + // Zรคhle aktive Poller + const activePollers = this.pollers.filter((p) => p.stats.running).length; + const totalPollers = this.pollers.length; + + // Formatiere die Domain-Statistiken (z.B. hotshpotshga:1) + const domainStats = stats.domains + .map((d) => { + const shortName = d.domain.split('.')[0].substring(0, 12); + return `${shortName}:${d.processed}`; + }) + .join(' | '); + + log( + `๐Ÿ“Š Status: ${activePollers}/${totalPollers} active, total:${stats.totalProcessed} | ${domainStats}`, + 'INFO', + 'unified-worker' + ); + } }