|
|
|
@ -9,22 +9,20 @@ import (
|
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/cron/job"
|
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/global"
|
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
|
|
|
|
"github.com/robfig/cron/v3"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Run() {
|
|
|
|
|
nyc, _ := time.LoadLocation("Asia/Shanghai")
|
|
|
|
|
nyc, _ := time.LoadLocation(common.LoadTimeZone())
|
|
|
|
|
Cron := cron.New(cron.WithLocation(nyc), cron.WithChain(cron.Recover(cron.DefaultLogger)), cron.WithChain(cron.DelayIfStillRunning(cron.DefaultLogger)))
|
|
|
|
|
_, err := Cron.AddJob("@every 5m", job.NewMonitorJob())
|
|
|
|
|
if err != nil {
|
|
|
|
|
if _, err := Cron.AddJob("@every 5m", job.NewMonitorJob()); err != nil {
|
|
|
|
|
global.LOG.Errorf("can not add monitor corn job: %s", err.Error())
|
|
|
|
|
}
|
|
|
|
|
_, err = Cron.AddJob("@daily", job.NewWebsiteJob())
|
|
|
|
|
if err != nil {
|
|
|
|
|
if _, err := Cron.AddJob("@daily", job.NewWebsiteJob()); err != nil {
|
|
|
|
|
global.LOG.Errorf("can not add website corn job: %s", err.Error())
|
|
|
|
|
}
|
|
|
|
|
_, err = Cron.AddJob("@daily", job.NewSSLJob())
|
|
|
|
|
if err != nil {
|
|
|
|
|
if _, err := Cron.AddJob("@daily", job.NewSSLJob()); err != nil {
|
|
|
|
|
global.LOG.Errorf("can not add ssl corn job: %s", err.Error())
|
|
|
|
|
}
|
|
|
|
|
Cron.Start()
|
|
|
|
|