Skip to content

Commit

Permalink
feat: 修改自动任务日志描述
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jan 2, 2025
1 parent 50d988a commit 47fbbe7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions internal/job/cert_renew.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (r *CertRenew) Run() {

var certs []biz.Cert
if err := r.db.Preload("Website").Preload("Account").Preload("DNS").Find(&certs).Error; err != nil {
r.log.Warn("获取证书失败", slog.Any("err", err))
r.log.Warn("[Cert Renew] failed to get certs", slog.Any("err", err))
return
}

Expand All @@ -58,19 +58,19 @@ func (r *CertRenew) Run() {

_, err = r.certRepo.Renew(cert.ID)
if err != nil {
r.log.Warn("续签证书失败", slog.Any("err", err))
r.log.Warn("[Cert Renew] failed to renew cert", slog.Any("err", err))
}
}

// 续签面板证书
panelCert, err := io.Read(filepath.Join(app.Root, "panel/storage/cert.pem"))
if err != nil {
r.log.Warn("读取面板证书失败", slog.Any("err", err))
r.log.Warn("[Cert Renew] failed to read panel cert", slog.Any("err", err))
return
}
decode, err := pkgcert.ParseCert(panelCert)
if err != nil {
r.log.Warn("解析面板证书失败", slog.Any("err", err))
r.log.Warn("[Cert Renew] failed to parse panel cert", slog.Any("err", err))
return
}
if decode.NotAfter.Sub(time.Now()).Hours() < 24*7 {

Check failure on line 76 in internal/job/cert_renew.go

View workflow job for this annotation

GitHub Actions / golanci-lint

S1024: should use time.Until instead of t.Sub(time.Now()) (gosimple)
Expand Down
4 changes: 2 additions & 2 deletions internal/job/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *Monitoring) Run() {
}

if err = r.db.Create(&biz.Monitor{Info: info}).Error; err != nil {
r.log.Warn("记录系统监控失败", slog.Any("err", err))
r.log.Warn("[Monitor] failed to create monitor record", slog.Any("err", err))
return
}

Expand All @@ -62,7 +62,7 @@ func (r *Monitoring) Run() {
return
}
if err = r.db.Where("created_at < ?", time.Now().AddDate(0, 0, -day).Format(time.DateTime)).Delete(&biz.Monitor{}).Error; err != nil {
r.log.Warn("删除过期系统监控失败", slog.Any("err", err))
r.log.Warn("[Monitor] failed to delete monitor record", slog.Any("err", err))
return
}
}
10 changes: 5 additions & 5 deletions internal/job/panel_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ func (r *PanelTask) Run() {
// 优化数据库
if err := r.db.Exec("VACUUM").Error; err != nil {
app.Status = app.StatusFailed
r.log.Warn("优化面板数据库失败", slog.Any("err", err))
r.log.Warn("[Panel Task] failed to vacuum database", slog.Any("err", err))
}
if err := r.db.Exec("PRAGMA wal_checkpoint(TRUNCATE);").Error; err != nil {
app.Status = app.StatusFailed
r.log.Warn("优化面板数据库失败", slog.Any("err", err))
r.log.Warn("[Panel Task] failed to wal checkpoint database", slog.Any("err", err))
}

// 备份面板
Expand All @@ -54,15 +54,15 @@ func (r *PanelTask) Run() {
path, err := r.backupRepo.GetPath("panel")
if err == nil {
if err = r.backupRepo.ClearExpired(path, "panel_", 10); err != nil {
r.log.Warn("清理面板备份失败", slog.Any("err", err))
r.log.Warn("[Panel Task] failed to clear backup", slog.Any("err", err))
}
}

// 更新商店缓存
time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() {
if offline, err := r.settingRepo.GetBool(biz.SettingKeyOfflineMode); err == nil && !offline {
if err = r.cacheRepo.UpdateApps(); err != nil {
r.log.Warn("更新商店缓存失败", slog.Any("err", err))
r.log.Warn("[Panel Task] failed to update apps cache", slog.Any("err", err))
}
}
})
Expand All @@ -71,7 +71,7 @@ func (r *PanelTask) Run() {
time.AfterFunc(time.Duration(rand.IntN(300))*time.Second, func() {
if offline, err := r.settingRepo.GetBool(biz.SettingKeyOfflineMode); err == nil && !offline {
if err = r.cacheRepo.UpdateRewrites(); err != nil {
r.log.Warn("更新伪静态缓存失败", slog.Any("err", err))
r.log.Warn("[Panel Task] failed to update rewrites cache", slog.Any("err", err))
}
}
})
Expand Down

0 comments on commit 47fbbe7

Please sign in to comment.