mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(cron): add automatic log cleanup with retention policy
Implement LogCleaner cron job to automatically clean up old log records based on configurable retention period and maximum record count. - Add LogCleaner with retention_days and max_records configuration - Add EZ_LOG_RETENTION_DAYS and EZ_LOG_MAX_RECORDS environment variables - Default to 30 days retention and 1,000,000 max records - Include unit tests for log cleaner functionality
This commit is contained in:
@@ -107,6 +107,10 @@ func main() {
|
||||
quotaCtx, cancelQuota := context.WithCancel(context.Background())
|
||||
defer cancelQuota()
|
||||
go quotaResetter.Start(quotaCtx)
|
||||
logCleaner := cron.NewLogCleaner(db, rdb, cfg.Log.RetentionDays, int64(cfg.Log.MaxRecords), time.Hour)
|
||||
cleanerCtx, cancelCleaner := context.WithCancel(context.Background())
|
||||
defer cancelCleaner()
|
||||
go logCleaner.Start(cleanerCtx)
|
||||
|
||||
adminService, err := service.NewAdminService()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user