Add an auto-cleanup worker

This commit is contained in:
nemunaire 2025-10-18 12:25:27 +07:00
commit 4304784796
5 changed files with 136 additions and 7 deletions

View file

@ -22,6 +22,7 @@
package app
import (
"context"
"log"
"os"
@ -49,6 +50,12 @@ func RunServer(cfg *config.Config) error {
log.Printf("Connected to %s database", cfg.Database.Type)
// Start cleanup service for old reports
ctx := context.Background()
cleanupSvc := NewCleanupService(store, cfg.ReportRetention)
cleanupSvc.Start(ctx)
defer cleanupSvc.Stop()
// Start LMTP server in background
go func() {
if err := lmtp.StartServer(cfg.Email.LMTPAddr, store, cfg); err != nil {