2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-06 18:47:31 +08:00

feat: 在面板定时任务出错时将面板设置为错误状态

This commit is contained in:
耗子
2024-04-05 21:12:14 +08:00
parent 0e9761f975
commit 841e0e351f

View File

@@ -37,6 +37,7 @@ func (receiver *PanelTask) Handle(ctx console.Context) error {
// 优化数据库
if _, err := facades.Orm().Query().Exec("VACUUM"); err != nil {
internal.Status = internal.StatusFailed
facades.Log().Tags("面板", "每日任务").
With(map[string]any{
"error": err.Error(),
@@ -46,6 +47,7 @@ func (receiver *PanelTask) Handle(ctx console.Context) error {
// 备份面板
if err := tools.Archive([]string{"/www/panel"}, "/www/backup/panel/panel-"+carbon.Now().ToShortDateTimeString()+".zip"); err != nil {
internal.Status = internal.StatusFailed
facades.Log().Tags("面板", "每日任务").
With(map[string]any{
"error": err.Error(),
@@ -55,6 +57,7 @@ func (receiver *PanelTask) Handle(ctx console.Context) error {
// 清理 7 天前的备份
if _, err := tools.Exec(`find /www/backup/panel -mtime +7 -name "*.zip" -exec rm -rf {} \;`); err != nil {
internal.Status = internal.StatusFailed
facades.Log().Tags("面板", "每日任务").
With(map[string]any{
"error": err.Error(),