Cleaned-up the cleanup loop

This commit is contained in:
Caleb Gardner
2025-05-08 02:24:54 -05:00
parent 24b99d7d1e
commit 3e1078efec
+6 -1
View File
@@ -75,7 +75,13 @@ func NewBackend(keyTable Table[ApiKey], apps ...App) (*Backend, error) {
} }
func (b *Backend) cleanupLoop() { func (b *Backend) cleanupLoop() {
b.cleanup()
for range time.Tick(24 * time.Hour) { for range time.Tick(24 * time.Hour) {
b.cleanup()
}
}
func (b *Backend) cleanup() {
old := getDate(time.Now().Add(-30 * 24 * time.Hour)) old := getDate(time.Now().Add(-30 * 24 * time.Hour))
var err error var err error
for _, a := range b.apps { for _, a := range b.apps {
@@ -89,7 +95,6 @@ func (b *Backend) cleanupLoop() {
log.Printf("error removing old logs for %v: %v\n", a.AppID(), err) log.Printf("error removing old logs for %v: %v\n", a.AppID(), err)
} }
} }
}
} }
// Enable CORS for with the given cors address // Enable CORS for with the given cors address