aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/main.go b/main.go
index 261c247..b4ea011 100644
--- a/main.go
+++ b/main.go
@@ -2,6 +2,7 @@ package main
import (
"sync"
+ "time"
"git.capotej.com/capotej/communique/cgi"
"git.capotej.com/capotej/communique/config"
@@ -41,13 +42,18 @@ func main() {
}
defer db.Close()
- log.With("type", "db").Debug("Running GC")
- err = db.RunValueLogGC(0.5)
- if err == badger.ErrNoRewrite {
- log.With("type", "db").Debug("Nothing to GC")
- } else {
- log.Fatal(err)
- }
+ ticker := time.NewTicker(5 * time.Minute)
+ defer ticker.Stop()
+
+ go func() {
+ for {
+ select {
+ case _ = <-ticker.C:
+ log.With("type", "db").Debug("Running GC")
+ db.RunValueLogGC(0.7)
+ }
+ }
+ }()
// Persister
persister := models.NewPersister(log, db)