mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-08 13:39:53 +00:00
28 lines
419 B
Go
28 lines
419 B
Go
package app
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
_ "time/tzdata"
|
|
|
|
"github.com/pocketbase/pocketbase/tools/cron"
|
|
)
|
|
|
|
var scheduler *cron.Cron
|
|
|
|
var schedulerOnce sync.Once
|
|
|
|
func GetScheduler() *cron.Cron {
|
|
scheduler = GetApp().Cron()
|
|
schedulerOnce.Do(func() {
|
|
location, err := time.LoadLocation("Local")
|
|
if err == nil {
|
|
scheduler.Stop()
|
|
scheduler.SetTimezone(location)
|
|
scheduler.Start()
|
|
}
|
|
})
|
|
|
|
return scheduler
|
|
}
|