Use better cron package

This commit is contained in:
maru committed 2024-04-16 21:01:24 -04:00
1 parent 420a4d17b3
commit 9477889390
5 files changed
+29 -56

No files matched your search

+10 -4
View File
@@ -10,14 +10,14 @@ import (
"os"
"time"
"github.com/go-co-op/gocron"
"github.com/pagefaultgames/pokerogue-server/db"
"github.com/robfig/cron/v3"
)
const secondsPerDay = 60 * 60 * 24
var (
scheduler = gocron.NewScheduler(time.UTC)
scheduler = cron.New()
secret []byte
)
@@ -51,8 +51,14 @@ func Init() error {
log.Printf("Daily Run Seed: %s", Seed())
scheduler.Every(1).Day().At("00:00").Do(recordNewDaily())
scheduler.StartAsync()
scheduler.AddFunc("@daily", func() {
err := recordNewDaily()
if err != nil {
log.Printf("error while recording new daily: %s", err)
}
})
scheduler.Start()
return nil
}