From d04c4bd425ee72f7a94920b2df942dc02026eec5 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 16 Aug 2023 23:44:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E8=A2=AB=E9=87=8D=E6=96=B0=E6=8B=89=E8=B5=B7?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20(#1977)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #1964 --- backend/app/service/host_tool.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/backend/app/service/host_tool.go b/backend/app/service/host_tool.go index 1ed671ed9..e7f57f56f 100644 --- a/backend/app/service/host_tool.go +++ b/backend/app/service/host_tool.go @@ -327,7 +327,10 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess if err = configFile.SaveTo(iniPath); err != nil { return err } - return operateSupervisorCtl("reload", "", "") + if err := operateSupervisorCtl("reread", "", ""); err != nil { + return err + } + return operateSupervisorCtl("update", "", "") case "update": configFile, err := ini.Load(iniPath) if err != nil { @@ -350,7 +353,10 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess if err = configFile.SaveTo(iniPath); err != nil { return err } - return operateSupervisorCtl("reload", "", "") + if err := operateSupervisorCtl("reread", "", ""); err != nil { + return err + } + return operateSupervisorCtl("update", "", "") case "restart": return operateSupervisorCtl("restart", req.Name, "") case "start": @@ -362,7 +368,10 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess _ = files.NewFileOp().DeleteFile(iniPath) _ = files.NewFileOp().DeleteFile(outLog) _ = files.NewFileOp().DeleteFile(errLog) - _ = operateSupervisorCtl("reload", "", "") + if err := operateSupervisorCtl("reread", "", ""); err != nil { + return err + } + return operateSupervisorCtl("update", "", "") } return nil @@ -387,22 +396,21 @@ func (h *HostToolService) LoadProcessStatus() []response.ProcessStatus { for i := 0; i < len(datas); i++ { go func(index int) { for t := 0; t < 3; t++ { - status, err := cmd.ExecWithTimeOut(fmt.Sprintf("supervisorctl status %s", datas[index].Name), 3*time.Second) + status, err := cmd.ExecWithTimeOut(fmt.Sprintf("supervisorctl status %s", datas[index].Name), 2*time.Second) if err != nil { - time.Sleep(2 * time.Second) + time.Sleep(1 * time.Second) continue } fields := strings.Fields(status) if len(fields) < 5 { - time.Sleep(2 * time.Second) + time.Sleep(1 * time.Second) continue } datas[index].Name = fields[0] datas[index].Status = fields[1] if fields[1] != "RUNNING" { datas[index].Msg = strings.Join(fields[2:], " ") - time.Sleep(1 * time.Second) - continue + break } datas[index].PID = strings.TrimSuffix(fields[3], ",") datas[index].Uptime = fields[5]