fix: 延长进程状态获取等待时间 (#1986)

release-1.5
ssongliu 1 year ago committed by wanghe-fit2cloud
parent 62d628c1aa
commit 27bd4a63ef

@ -161,6 +161,11 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) (string, error)
}
dockerLogDir := path.Join(global.CONF.System.TmpDir, "docker_logs")
if _, err := os.Stat(dockerLogDir); err != nil && os.IsNotExist(err) {
if err = os.MkdirAll(dockerLogDir, os.ModePerm); err != nil {
return "", err
}
}
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 {

@ -379,7 +379,7 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess
func (h *HostToolService) LoadProcessStatus() ([]response.ProcessStatus, error) {
var datas []response.ProcessStatus
statuLines, err := cmd.Exec("supervisorct status")
statuLines, err := cmd.Exec("supervisorctl status")
if err != nil {
return datas, fmt.Errorf("exec `supervisorctl status` failed, err: %v", statuLines)
}
@ -398,12 +398,12 @@ func (h *HostToolService) LoadProcessStatus() ([]response.ProcessStatus, error)
for t := 0; t < 3; t++ {
status, err := cmd.ExecWithTimeOut(fmt.Sprintf("supervisorctl status %s", datas[index].Name), 2*time.Second)
if err != nil {
time.Sleep(1 * time.Second)
time.Sleep(2 * time.Second)
continue
}
fields := strings.Fields(status)
if len(fields) < 5 {
time.Sleep(1 * time.Second)
time.Sleep(2 * time.Second)
continue
}
datas[index].Name = fields[0]

@ -123,7 +123,6 @@ func (u *ImageService) ImageBuild(req dto.ImageBuild) (string, error) {
return "", err
}
fileName := "Dockerfile"
dockerLogDir := path.Join(global.CONF.System.TmpDir, "docker_logs")
if req.From == "edit" {
dir := fmt.Sprintf("%s/docker/build/%s", constant.DataDir, strings.ReplaceAll(req.Name, ":", "_"))
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
@ -158,6 +157,12 @@ func (u *ImageService) ImageBuild(req dto.ImageBuild) (string, error) {
Labels: stringsToMap(req.Tags),
}
dockerLogDir := path.Join(global.CONF.System.TmpDir, "docker_logs")
if _, err := os.Stat(dockerLogDir); err != nil && os.IsNotExist(err) {
if err = os.MkdirAll(dockerLogDir, os.ModePerm); err != nil {
return "", err
}
}
logItem := fmt.Sprintf("%s/image_build_%s_%s.log", dockerLogDir, strings.ReplaceAll(req.Name, ":", "_"), time.Now().Format("20060102150405"))
file, err := os.OpenFile(logItem, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {

@ -1,7 +1,7 @@
<template>
<div>
<div style="display: flex; flex-wrap: wrap">
<el-select @change="searchLogs" v-model="logSearch.mode" style="width: 100px">
<el-select @change="searchLogs" v-model="logSearch.mode" style="width: 150px">
<template #prefix>{{ $t('container.fetch') }}</template>
<el-option v-for="item in timeOptions" :key="item.label" :value="item.value" :label="item.label" />
</el-select>

@ -235,10 +235,10 @@ const submit = async (formEl: FormInstance | undefined) => {
const getProtocolAndHost = (url: string): { protocol: string; host: string } | null => {
if (url.startsWith('https://')) {
return { protocol: 'https', host: url.replaceAll('https://', '') };
return { protocol: 'https://', host: url.replaceAll('https://', '') };
}
if (url.startsWith('http://')) {
return { protocol: 'http', host: url.replaceAll('http://', '') };
return { protocol: 'http://', host: url.replaceAll('http://', '') };
}
return { protocol: '', host: url };
};

Loading…
Cancel
Save