mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-10 09:02:42 +08:00
feat: 优化计划任务脚本执行错误处理 (#2635)
This commit is contained in:
parent
7716df55f9
commit
604949de18
7 changed files with 20 additions and 31 deletions
|
@ -133,3 +133,8 @@ var (
|
|||
var (
|
||||
ErrFirewall = "ErrFirewall"
|
||||
)
|
||||
|
||||
// cronjob
|
||||
var (
|
||||
ErrBashExecute = "ErrBashExecute"
|
||||
)
|
||||
|
|
|
@ -124,4 +124,7 @@ ErrConfigAlreadyExist: "A configuration file with the same name already exists"
|
|||
ErrUserFindErr: "Failed to find user {{ .name }} {{ .err }}"
|
||||
|
||||
#ssh
|
||||
ErrFirewall: "No firewalld or ufw service is detected. Please check and try again!"
|
||||
ErrFirewall: "No firewalld or ufw service is detected. Please check and try again!"
|
||||
|
||||
#cronjob
|
||||
ErrBashExecute: "Script execution error, please check stderr-related information in the task output text field."
|
|
@ -124,4 +124,7 @@ ErrConfigAlreadyExist: "已存在同名配置文件"
|
|||
ErrUserFindErr: "用戶 {{ .name }} 查找失敗 {{ .err }}"
|
||||
|
||||
#ssh
|
||||
ErrFirewall: "當前未檢測到系統 firewalld 或 ufw 服務,請檢查後重試!"
|
||||
ErrFirewall: "當前未檢測到系統 firewalld 或 ufw 服務,請檢查後重試!"
|
||||
|
||||
#cronjob
|
||||
ErrBashExecute: "腳本執行錯誤,請在任務輸出文本區域中查看 stderr 相關信息。"
|
|
@ -125,3 +125,6 @@ ErrUserFindErr: "用户 {{ .name }} 查找失败 {{ .err }}"
|
|||
|
||||
#ssh
|
||||
ErrFirewall: "当前未检测到系统 firewalld 或 ufw 服务,请检查后重试!"
|
||||
|
||||
#cronjob
|
||||
ErrBashExecute: "脚本执行错误,请在任务输出文本域中查看 stderr 相关信息。"
|
||||
|
|
|
@ -95,11 +95,12 @@ func ExecCronjobWithTimeOut(cmdStr string, workdir string, timeout time.Duration
|
|||
|
||||
errMsg := ""
|
||||
if len(stderr.String()) != 0 {
|
||||
errMsg = fmt.Sprintf("stderr:\n %s", stderr.String())
|
||||
errMsg = fmt.Sprintf("stderr:\n%s", stderr.String())
|
||||
err = buserr.New(constant.ErrBashExecute)
|
||||
}
|
||||
if len(stdout.String()) != 0 {
|
||||
if len(errMsg) != 0 {
|
||||
errMsg = fmt.Sprintf("%s \n\n; stdout:\n %s", errMsg, stdout.String())
|
||||
errMsg = fmt.Sprintf("%s \n\n stdout:\n%s", errMsg, stdout.String())
|
||||
} else {
|
||||
errMsg = fmt.Sprintf("stdout:\n %s", stdout.String())
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package encrypt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/init/viper"
|
||||
)
|
||||
|
||||
func TestStringEncrypt(t *testing.T) {
|
||||
viper.Init()
|
||||
p, err := StringEncrypt("1Panel@2022")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println(p)
|
||||
}
|
||||
|
||||
func TestStringDecrypt(t *testing.T) {
|
||||
viper.Init()
|
||||
p, err := StringDecrypt("dXn5bVtea+KVLDrLJlpnPIJNfW8TAMmqX1QNMdSGp88=")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println(p)
|
||||
}
|
|
@ -77,7 +77,7 @@
|
|||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('cronjob.cronSpec')" :min-width="120">
|
||||
<el-table-column :label="$t('cronjob.cronSpec')" show-overflow-tooltip :min-width="120">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.specType.indexOf('N') === -1 || row.specType === 'perWeek'">
|
||||
{{ $t('cronjob.' + row.specType) }}
|
||||
|
|
Loading…
Reference in a new issue