Skip to content

Commit

Permalink
fix: 解决定时任务停止网站失败的问题 (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 authored May 8, 2023
1 parent f22caed commit 8c5c244
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/cron/job/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ func (w *website) Run() {
nyc, _ := time.LoadLocation(common.LoadTimeZone())
websites, _ := repo.NewIWebsiteRepo().List()
global.LOG.Info("Website scheduled task in progress ...")
now := time.Now().Add(10 * time.Second)
now := time.Now().Add(10 * time.Minute)
if len(websites) > 0 {
neverExpireDate, _ := time.Parse(constant.DateLayout, constant.DefaultDate)
var wg sync.WaitGroup
for _, site := range websites {
if site.Status != constant.WebRunning || neverExpireDate.Equal(site.ExpireDate) {
continue
}
expireDate, _ := time.ParseInLocation(constant.DateTimeLayout, site.ExpireDate.String(), nyc)
expireDate, err := time.ParseInLocation(constant.DateLayout, site.ExpireDate.Format(constant.DateLayout), nyc)
if err != nil {
global.LOG.Errorf("time parse err %v", err)
continue
}
if expireDate.Before(now) {
wg.Add(1)
go func(ws model.Website) {
Expand Down

0 comments on commit 8c5c244

Please sign in to comment.