printstats

This commit is contained in:
Andreas Knuth 2026-03-07 16:44:53 -06:00
parent 12af8577f3
commit 757855866c
1 changed files with 28 additions and 0 deletions

View File

@ -23,6 +23,7 @@ export class UnifiedWorker {
private pollers: DomainPoller[] = []; private pollers: DomainPoller[] = [];
private processor: MessageProcessor; private processor: MessageProcessor;
private sqs: SQSHandler; private sqs: SQSHandler;
private statusInterval: NodeJS.Timeout | null = null;
constructor( constructor(
private domains: string[], private domains: string[],
@ -78,10 +79,16 @@ export class UnifiedWorker {
this.pollers.map((p) => p.stats.domain).join(', '), this.pollers.map((p) => p.stats.domain).join(', '),
'SUCCESS', 'SUCCESS',
); );
// Starte den 5-Minuten-Status-Report
this.statusInterval = setInterval(() => {
this.printStatus();
}, 5 * 60 * 1000);
} }
async stop(): Promise<void> { async stop(): Promise<void> {
log('🛑 Stopping all domain pollers...'); log('🛑 Stopping all domain pollers...');
if (this.statusInterval) clearInterval(this.statusInterval); // <-- Neue Zeile
await Promise.all(this.pollers.map((p) => p.stop())); await Promise.all(this.pollers.map((p) => p.stop()));
log('✅ All pollers stopped.'); log('✅ All pollers stopped.');
} }
@ -103,4 +110,25 @@ export class UnifiedWorker {
return { totalProcessed, totalErrors, domains }; 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'
);
}
} }