1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 16:29:17 +08:00

fix: 解决暂停进程被重新拉起的问题 (#1977)

Refs #1964
This commit is contained in:
ssongliu 2023-08-16 23:44:11 +08:00 committed by GitHub
parent 8135f0f598
commit d04c4bd425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -327,7 +327,10 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess
if err = configFile.SaveTo(iniPath); err != nil { if err = configFile.SaveTo(iniPath); err != nil {
return err return err
} }
return operateSupervisorCtl("reload", "", "") if err := operateSupervisorCtl("reread", "", ""); err != nil {
return err
}
return operateSupervisorCtl("update", "", "")
case "update": case "update":
configFile, err := ini.Load(iniPath) configFile, err := ini.Load(iniPath)
if err != nil { if err != nil {
@ -350,7 +353,10 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess
if err = configFile.SaveTo(iniPath); err != nil { if err = configFile.SaveTo(iniPath); err != nil {
return err return err
} }
return operateSupervisorCtl("reload", "", "") if err := operateSupervisorCtl("reread", "", ""); err != nil {
return err
}
return operateSupervisorCtl("update", "", "")
case "restart": case "restart":
return operateSupervisorCtl("restart", req.Name, "") return operateSupervisorCtl("restart", req.Name, "")
case "start": case "start":
@ -362,7 +368,10 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess
_ = files.NewFileOp().DeleteFile(iniPath) _ = files.NewFileOp().DeleteFile(iniPath)
_ = files.NewFileOp().DeleteFile(outLog) _ = files.NewFileOp().DeleteFile(outLog)
_ = files.NewFileOp().DeleteFile(errLog) _ = files.NewFileOp().DeleteFile(errLog)
_ = operateSupervisorCtl("reload", "", "") if err := operateSupervisorCtl("reread", "", ""); err != nil {
return err
}
return operateSupervisorCtl("update", "", "")
} }
return nil return nil
@ -387,22 +396,21 @@ func (h *HostToolService) LoadProcessStatus() []response.ProcessStatus {
for i := 0; i < len(datas); i++ { for i := 0; i < len(datas); i++ {
go func(index int) { go func(index int) {
for t := 0; t < 3; t++ { 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 { if err != nil {
time.Sleep(2 * time.Second) time.Sleep(1 * time.Second)
continue continue
} }
fields := strings.Fields(status) fields := strings.Fields(status)
if len(fields) < 5 { if len(fields) < 5 {
time.Sleep(2 * time.Second) time.Sleep(1 * time.Second)
continue continue
} }
datas[index].Name = fields[0] datas[index].Name = fields[0]
datas[index].Status = fields[1] datas[index].Status = fields[1]
if fields[1] != "RUNNING" { if fields[1] != "RUNNING" {
datas[index].Msg = strings.Join(fields[2:], " ") datas[index].Msg = strings.Join(fields[2:], " ")
time.Sleep(1 * time.Second) break
continue
} }
datas[index].PID = strings.TrimSuffix(fields[3], ",") datas[index].PID = strings.TrimSuffix(fields[3], ",")
datas[index].Uptime = fields[5] datas[index].Uptime = fields[5]