mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
parent
7a3716a363
commit
5e7429cd51
@ -631,9 +631,9 @@ func (u *ContainerService) ContainerStats(id string) (*dto.ContainerStats, error
|
|||||||
func (u *ContainerService) LoadContainerLogs(req dto.OperationWithNameAndType) string {
|
func (u *ContainerService) LoadContainerLogs(req dto.OperationWithNameAndType) string {
|
||||||
filePath := ""
|
filePath := ""
|
||||||
switch req.Type {
|
switch req.Type {
|
||||||
case "image-pull", "image-push", "image-build":
|
case "image-pull", "image-push", "image-build", "compose-create":
|
||||||
filePath = path.Join(global.CONF.System.TmpDir, fmt.Sprintf("docker_logs/%s", req.Name))
|
filePath = path.Join(global.CONF.System.TmpDir, fmt.Sprintf("docker_logs/%s", req.Name))
|
||||||
case "compose-detail", "compose-create":
|
case "compose-detail":
|
||||||
client, err := docker.NewDockerClient()
|
client, err := docker.NewDockerClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
@ -159,8 +159,10 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) (string, error)
|
|||||||
if req.From == "path" {
|
if req.From == "path" {
|
||||||
req.Name = path.Base(path.Dir(req.Path))
|
req.Name = path.Base(path.Dir(req.Path))
|
||||||
}
|
}
|
||||||
logName := path.Dir(req.Path) + "/compose.log"
|
|
||||||
file, err := os.OpenFile(logName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
dockerLogDir := path.Join(global.CONF.System.TmpDir, "docker_logs")
|
||||||
|
logItem := fmt.Sprintf("%s/compose_create_%s_%s.log", dockerLogDir, req.Name, time.Now().Format("20060102150405"))
|
||||||
|
file, err := os.OpenFile(logItem, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -181,7 +183,7 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) (string, error)
|
|||||||
_, _ = file.WriteString("docker-compose up successful!")
|
_, _ = file.WriteString("docker-compose up successful!")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return req.Name, nil
|
return path.Base(logItem), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *ContainerService) ComposeOperation(req dto.ComposeOperation) error {
|
func (u *ContainerService) ComposeOperation(req dto.ComposeOperation) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user