fix: 解决服务重启后计划任务状态错误的问题 (#3741)

This commit is contained in:
ssongliu 2024-01-29 16:34:57 +08:00 committed by GitHub
parent 10eef260d4
commit a5304b66e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ package hook
import (
"encoding/base64"
"github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/backend/app/repo"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/global"
@ -70,6 +71,7 @@ func Init() {
_, _ = cmd.Execf("%s sed -i '/CHANGE_USER_INFO=true/d' /usr/local/bin/1pctl", sudo)
}
handleCronjobStatus()
handleSnapStatus()
}
@ -117,3 +119,11 @@ func handleSnapStatus() {
}
}
}
func handleCronjobStatus() {
_ = global.DB.Model(&model.JobRecords{}).Where("status = ?", constant.StatusWaiting).
Updates(map[string]interface{}{
"status": constant.StatusFailed,
"message": "the task was interrupted due to the restart of the 1panel service",
}).Error
}