🎨 Improve the marketplace refresh timer https://github.com/siyuan-note/siyuan/issues/14685

This commit is contained in:
Daniel 2025-04-25 11:00:27 +08:00
parent 99d4ad4bd4
commit 06a6365cd5
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017

View File

@ -32,7 +32,7 @@ func StartCron() {
go every(5*time.Second, task.StatusJob)
go every(5*time.Second, model.SyncDataJob)
go every(2*time.Hour, model.StatJob)
go every(6*time.Hour, util.RefreshRhyResultJob)
go every(6*time.Hour, util.RefreshRhyResultJob, "RefreshRhyResultJob")
go every(2*time.Hour, model.RefreshCheckJob)
go every(3*time.Second, model.FlushUpdateRefTextRenameDocJob)
go every(util.SQLFlushInterval, sql.FlushTxJob)
@ -50,14 +50,17 @@ func StartCron() {
//go every(3*time.Second, model.WatchLocalShorthands)
}
func every(interval time.Duration, f func()) {
func every(interval time.Duration, f func(), name ...string) {
util.RandomSleep(50, 200)
for {
ticker := time.NewTicker(interval)
defer ticker.Stop()
for range ticker.C {
func() {
defer logging.Recover()
f()
if 0 < len(name) {
logging.LogInfof("cron job [%s] executed", name)
}
}()
time.Sleep(interval)
}
}