mirror of
https://github.com/alireza0/x-ui.git
synced 2026-10-20 18:51:33 +00:00
fix cron timezone #1648
This commit is contained in:
parent
f1b4b751ee
commit
982d996e89
2 changed files with 14 additions and 5 deletions
|
|
@ -135,6 +135,10 @@ func (s *AllSetting) CheckValid() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if _, err := cronspec.Parse(s.TgRunTime); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := time.LoadLocation(s.TimeLocation)
|
||||
if err != nil {
|
||||
return common.NewError("time location not exist:", s.TimeLocation)
|
||||
|
|
|
|||
15
web/web.go
15
web/web.go
|
|
@ -280,14 +280,19 @@ func (s *Server) startTask() {
|
|||
if (err == nil) && (isTgbotenabled) {
|
||||
runtime, err := s.settingService.GetTgbotRuntime()
|
||||
if err != nil || runtime == "" {
|
||||
logger.Errorf("Add NewStatsNotifyJob error[%s], Runtime[%s] invalid, will run default", err, runtime)
|
||||
logger.Errorf("Add NewStatsNotifyJob error[%v], Runtime[%s] invalid, will run default", err, runtime)
|
||||
runtime = "@daily"
|
||||
}
|
||||
logger.Infof("Tg notify enabled,run at %s", runtime)
|
||||
_, err = s.cron.AddJob(runtime, job.NewStatsNotifyJob())
|
||||
// The scheduler's own parser demands a seconds field, so hand it the
|
||||
// schedule already parsed to accept standard five-field crontab too.
|
||||
schedule, err := cronspec.Parse(runtime)
|
||||
if err != nil {
|
||||
logger.Warning("Add NewStatsNotifyJob error", err)
|
||||
return
|
||||
logger.Warning("Add NewStatsNotifyJob error, will run default:", err)
|
||||
schedule, _ = cronspec.Parse("@daily")
|
||||
}
|
||||
if schedule != nil {
|
||||
logger.Infof("Tg notify enabled,run at %s", runtime)
|
||||
s.cron.Schedule(schedule, job.NewStatsNotifyJob())
|
||||
}
|
||||
|
||||
// Check CPU load and alarm to TgBot if threshold passes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue