mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 14:57:16 +08:00
finish translation for panel.cutoff
This commit is contained in:
@@ -242,11 +242,11 @@ func (receiver *Panel) Handle(ctx console.Context) error {
|
||||
case "cleanTask":
|
||||
_, err := facades.Orm().Query().Model(&models.Task{}).Where("status", models.TaskStatusRunning).OrWhere("status", models.TaskStatusWaiting).Update("status", models.TaskStatusFailed)
|
||||
if err != nil {
|
||||
color.Redln("清理任务失败")
|
||||
color.Redln(translate.Get("commands.panel.cleanTask.fail"))
|
||||
return nil
|
||||
}
|
||||
|
||||
color.Greenln("清理任务成功")
|
||||
color.Greenln(translate.Get("commands.panel.cleanTask.success"))
|
||||
|
||||
case "backup":
|
||||
backupType := arg1
|
||||
@@ -401,44 +401,44 @@ func (receiver *Panel) Handle(ctx console.Context) error {
|
||||
save := arg2
|
||||
hr := `+----------------------------------------------------`
|
||||
if len(name) == 0 || len(save) == 0 {
|
||||
color.Redln("参数错误")
|
||||
color.Redln(translate.Get("commands.panel.cutoff.paramFail"))
|
||||
return nil
|
||||
}
|
||||
|
||||
color.Greenln(hr)
|
||||
color.Greenln("★ 开始切割 [" + carbon.Now().ToDateTimeString() + "]")
|
||||
color.Greenln("★ " + translate.Get("commands.panel.cutoff.start") + " [" + carbon.Now().ToDateTimeString() + "]")
|
||||
color.Greenln(hr)
|
||||
|
||||
color.Yellowln("|-目标网站: " + name)
|
||||
color.Yellowln("|-" + translate.Get("commands.panel.cutoff.targetSite") + ": " + name)
|
||||
var website models.Website
|
||||
if err := facades.Orm().Query().Where("name", name).FirstOrFail(&website); err != nil {
|
||||
color.Redln("|-网站不存在")
|
||||
color.Redln("|-" + translate.Get("commands.panel.cutoff.siteNotExist"))
|
||||
color.Greenln(hr)
|
||||
return nil
|
||||
}
|
||||
|
||||
logPath := "/www/wwwlogs/" + website.Name + ".log"
|
||||
if !tools.Exists(logPath) {
|
||||
color.Redln("|-日志文件不存在")
|
||||
color.Redln("|-" + translate.Get("commands.panel.cutoff.logNotExist"))
|
||||
color.Greenln(hr)
|
||||
return nil
|
||||
}
|
||||
|
||||
backupPath := "/www/wwwlogs/" + website.Name + "_" + carbon.Now().ToShortDateTimeString() + ".log.zip"
|
||||
if _, err := tools.Exec(`cd /www/wwwlogs && zip -r ` + backupPath + ` ` + website.Name + ".log"); err != nil {
|
||||
color.Redln("|-备份失败: " + err.Error())
|
||||
color.Redln("|-" + translate.Get("commands.panel.cutoff.backupFail") + ": " + err.Error())
|
||||
return nil
|
||||
}
|
||||
if _, err := tools.Exec(`echo "" > ` + logPath); err != nil {
|
||||
color.Redln("|-清空失败: " + err.Error())
|
||||
color.Redln("|-" + translate.Get("commands.panel.cutoff.clearFail") + ": " + err.Error())
|
||||
return nil
|
||||
}
|
||||
color.Greenln("|-切割成功")
|
||||
color.Greenln("|-" + translate.Get("commands.panel.cutoff.cutSuccess"))
|
||||
|
||||
color.Greenln(hr)
|
||||
files, err := os.ReadDir("/www/wwwlogs")
|
||||
if err != nil {
|
||||
color.Redln("|-清理失败: " + err.Error())
|
||||
color.Redln("|-" + translate.Get("commands.panel.cutoff.cleanupFail") + ": " + err.Error())
|
||||
return nil
|
||||
}
|
||||
var filteredFiles []os.FileInfo
|
||||
@@ -456,15 +456,15 @@ func (receiver *Panel) Handle(ctx console.Context) error {
|
||||
})
|
||||
for i := cast.ToInt(save); i < len(filteredFiles); i++ {
|
||||
fileToDelete := filepath.Join("/www/wwwlogs", filteredFiles[i].Name())
|
||||
color.Yellowln("|-清理日志: " + fileToDelete)
|
||||
color.Yellowln("|-" + translate.Get("commands.panel.cutoff.clearLog") + ": " + fileToDelete)
|
||||
if err := tools.Remove(fileToDelete); err != nil {
|
||||
color.Redln("|-清理失败: " + err.Error())
|
||||
color.Redln("|-" + translate.Get("commands.panel.cutoff.cleanupFail") + ": " + err.Error())
|
||||
return nil
|
||||
}
|
||||
}
|
||||
color.Greenln("|-清理完成")
|
||||
color.Greenln("|-" + translate.Get("commands.panel.cutoff.cleanupSuccess"))
|
||||
color.Greenln(hr)
|
||||
color.Greenln("☆ 切割完成 [" + carbon.Now().ToDateTimeString() + "]")
|
||||
color.Greenln("☆ " + translate.Get("commands.panel.cutoff.end") + " [" + carbon.Now().ToDateTimeString() + "]")
|
||||
color.Greenln(hr)
|
||||
|
||||
case "writeSite":
|
||||
|
||||
18
lang/en.json
18
lang/en.json
@@ -42,13 +42,27 @@
|
||||
"success": "panel entrance deleted successfully"
|
||||
},
|
||||
"cleanTask": {
|
||||
"description": "clean up running and waiting tasks in the panel [used when tasks are stuck]"
|
||||
"description": "clean up running and waiting tasks in the panel [used when tasks are stuck]",
|
||||
"fail": "failed to clean up tasks",
|
||||
"success": "tasks cleaned up successfully"
|
||||
},
|
||||
"backup": {
|
||||
"description": "back up website/MySQL database/PostgreSQL database to the specified directory and retain the specified amount"
|
||||
},
|
||||
"cutoff": {
|
||||
"description": "cut website logs and keep specified amount"
|
||||
"description": "cut website logs and keep specified amount",
|
||||
"paramFail": "website domain name and keep amount are required",
|
||||
"start": "start cutting",
|
||||
"targetSite": "target website",
|
||||
"siteNotExist": "website does not exist",
|
||||
"logNotExist": "log file does not exist",
|
||||
"backupFail": "backup failed",
|
||||
"clearFail": "clearing failed",
|
||||
"cleanupFail": "cleanup failed",
|
||||
"clearLog": "clear log",
|
||||
"cutSuccess": "cutting successful",
|
||||
"cleanupSuccess": "cleanup successful",
|
||||
"end": "cutting completed"
|
||||
},
|
||||
"installPlugin": {
|
||||
"description": "install plugin"
|
||||
|
||||
@@ -42,13 +42,27 @@
|
||||
"success": "删除面板入口成功"
|
||||
},
|
||||
"cleanTask": {
|
||||
"description": "清理面板运行中和等待中的任务[任务卡住时使用]"
|
||||
"description": "清理面板运行中和等待中的任务[任务卡住时使用]",
|
||||
"fail": "清理任务失败",
|
||||
"success": "清理任务成功"
|
||||
},
|
||||
"backup": {
|
||||
"description": "备份网站 / MySQL数据库 / PostgreSQL数据库到指定目录并保留指定数量"
|
||||
},
|
||||
"cutoff": {
|
||||
"description": "切割网站日志并保留指定数量"
|
||||
"description": "切割网站日志并保留指定数量",
|
||||
"paramFail": "参数错误",
|
||||
"start": "开始切割",
|
||||
"targetSite": "目标网站",
|
||||
"siteNotExist": "网站不存在",
|
||||
"logNotExist": "日志文件不存在",
|
||||
"backupFail": "备份失败",
|
||||
"clearFail": "清空失败",
|
||||
"cleanupFail": "清理失败",
|
||||
"clearLog": "清理日志",
|
||||
"cutSuccess": "切割成功",
|
||||
"cleanupSuccess": "清理完成",
|
||||
"end": "切割完成"
|
||||
},
|
||||
"installPlugin": {
|
||||
"description": "安装插件"
|
||||
|
||||
Reference in New Issue
Block a user