Add DB garbage collection

This commit is contained in:
Ash Keel 2021-12-05 22:17:52 +01:00
parent 4253875787
commit bcb15ab4a9
No known key found for this signature in database
GPG Key ID: BAD8D93E7314ED3E
1 changed files with 11 additions and 0 deletions

11
main.go
View File

@ -171,6 +171,17 @@ func main() {
log.WithError(err).Error("Error while listening to module config changes")
}()
// Run garbage collection every once in a while
ticker := time.NewTicker(15 * time.Minute)
defer ticker.Stop()
for range ticker.C {
// Run DB garbage collection until it's done
var err error
for err == nil {
err = db.Client().RunValueLogGC(0.5)
}
}
// Start HTTP server
failOnError(httpServer.Listen(), "HTTP server stopped")
}