mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 10:19:27 +08:00
improve efficiency of hourly cleanup operation
This commit is contained in:
20
hub/main.go
20
hub/main.go
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/plugins/migratecmd"
|
||||
"github.com/pocketbase/pocketbase/tools/cron"
|
||||
@@ -105,16 +106,15 @@ func main() {
|
||||
// cron job to delete old records
|
||||
scheduler := cron.New()
|
||||
scheduler.MustAdd("delete old records", "8 * * * *", func() {
|
||||
deleteOldRecords("system_stats", "1m", time.Hour)
|
||||
deleteOldRecords("container_stats", "1m", time.Hour)
|
||||
deleteOldRecords("system_stats", "10m", 12*time.Hour)
|
||||
deleteOldRecords("container_stats", "10m", 12*time.Hour)
|
||||
deleteOldRecords("system_stats", "20m", 24*time.Hour)
|
||||
deleteOldRecords("container_stats", "20m", 24*time.Hour)
|
||||
deleteOldRecords("system_stats", "120m", 7*24*time.Hour)
|
||||
deleteOldRecords("container_stats", "120m", 7*24*time.Hour)
|
||||
deleteOldRecords("system_stats", "480m", 30*24*time.Hour)
|
||||
deleteOldRecords("container_stats", "480m", 30*24*time.Hour)
|
||||
app.Dao().RunInTransaction(func(txDao *daos.Dao) error {
|
||||
collections := []string{"system_stats", "container_stats"}
|
||||
deleteOldRecords(txDao, collections, "1m", time.Hour)
|
||||
deleteOldRecords(txDao, collections, "10m", 12*time.Hour)
|
||||
deleteOldRecords(txDao, collections, "20m", 24*time.Hour)
|
||||
deleteOldRecords(txDao, collections, "120m", 7*24*time.Hour)
|
||||
deleteOldRecords(txDao, collections, "480m", 30*24*time.Hour)
|
||||
return nil
|
||||
})
|
||||
})
|
||||
scheduler.Start()
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user