1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-01 03:24:14 +08:00

fix: Adjust the container task log (#8025)

This commit is contained in:
ssongliu 2025-02-27 15:04:25 +08:00 committed by GitHub
parent 24cabd214b
commit aae839f921
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 5 deletions

View File

@ -11,7 +11,6 @@ import (
"net/url" "net/url"
"os" "os"
"os/exec" "os/exec"
"path"
"path/filepath" "path/filepath"
"sort" "sort"
"strconv" "strconv"
@ -343,8 +342,7 @@ func (u *ContainerService) ContainerCreateByCommand(req dto.ContainerCreateByCom
} }
go func() { go func() {
taskItem.AddSubTask(i18n.GetWithName("ContainerCreate", containerName), func(t *task.Task) error { taskItem.AddSubTask(i18n.GetWithName("ContainerCreate", containerName), func(t *task.Task) error {
logPath := path.Join(global.Dir.LogDir, task.TaskScopeContainer, req.TaskID+".log") return cmd.ExecShellWithTask(taskItem, 5*time.Minute, "bash", "-c", req.Command)
return cmd.ExecShell(logPath, 5*time.Minute, "bash", "-c", req.Command)
}, nil) }, nil)
_ = taskItem.Execute() _ = taskItem.Execute()
}() }()
@ -507,7 +505,6 @@ func (u *ContainerService) ContainerCreate(req dto.ContainerOperate) error {
return err return err
} }
con, err := client.ContainerCreate(ctx, config, hostConf, networkConf, &v1.Platform{}, req.Name) con, err := client.ContainerCreate(ctx, config, hostConf, networkConf, &v1.Platform{}, req.Name)
taskItem.LogWithStatus(i18n.GetMsgByKey("ContainerCreate"), err)
if err != nil { if err != nil {
taskItem.Log(i18n.GetMsgByKey("ContainerCreateFailed")) taskItem.Log(i18n.GetMsgByKey("ContainerCreateFailed"))
_ = client.ContainerRemove(ctx, req.Name, container.RemoveOptions{RemoveVolumes: true, Force: true}) _ = client.ContainerRemove(ctx, req.Name, container.RemoveOptions{RemoveVolumes: true, Force: true})

View File

@ -129,7 +129,7 @@ const rules = reactive({
name: [{ validator: checkName, trigger: 'blur' }], name: [{ validator: checkName, trigger: 'blur' }],
}); });
function checkName(rule: any, value: any, callback: any) { function checkName(rule: any, value: any, callback: any) {
if (value === 'local') { if (value === 'local' && dialogData.value.title !== 'edit') {
return callback(new Error(i18n.global.t('terminal.localHelper'))); return callback(new Error(i18n.global.t('terminal.localHelper')));
} }
callback(); callback();