test deploy
alex wennerberg alex@alexwennerberg.com
Wed, 27 Jan 2021 16:10:27 -0800
M
log.go
→
log.go
@@ -240,6 +240,13 @@ }
return &result, nil } +func dumpLogsWorker() { + log.Println("Starting analytics log writing worker") + for { + dumpLogs() + time.Sleep(time.Minute * 5) + } +} func dumpLogs() { log.Println("Writing missing logs to database") db, err := getAnalyticsDB()@@ -281,6 +288,7 @@ ll.insertInto(db)
counter += 1 } log.Printf("Wrote %d logs\n", counter) + panic(nil) } func rotateLogs() {
M
main.go
→
main.go
@@ -40,10 +40,8 @@
cookie := generateCookieKeyIfDNE() SessionStore = sessions.NewCookieStore(cookie) - // handle background tasks - // s1 := gocron.NewScheduler(time.UTC) if c.AnalyticsDBFile != "" { - // s1.Every(5).Minute().Do(dumpLogs) + go dumpLogsWorker() } // load domains in memory