프로세스 재시작 요청 추가
This commit is contained in:
@ -452,52 +452,35 @@ func (hc *houstonClient) stopChildProcess(req *shared.StopProcessRequest, op pro
|
||||
}
|
||||
|
||||
func (hc *houstonClient) restartChildProcess(req *shared.RestartProcessRequest, op protos.OperationClient) error {
|
||||
if req.Version == "latest" {
|
||||
// 최신 버전을 찾음
|
||||
latest, err := shared.FindLastestVersion(hc.config.StorageRoot, req.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req.Version = latest
|
||||
}
|
||||
|
||||
var restarts []*procmeta
|
||||
for _, proc := range hc.childProcs {
|
||||
if proc.name == req.Name {
|
||||
if len(req.Version) == 0 {
|
||||
restarts = append(restarts, proc)
|
||||
} else if req.Version == proc.version {
|
||||
restarts = append(restarts, proc)
|
||||
if proc.cmd.Process.Pid == int(req.Pid) {
|
||||
if len(req.Config) > 0 {
|
||||
// config.json를 먼저 다운로드 시도
|
||||
root := proc.cmd.Path
|
||||
if _, err := download(root, hc.makeDownloadUrl(req.Config), ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := proc.cmd.Process.Signal(syscall.SIGTERM); err != nil {
|
||||
proc.cmd.Process.Signal(os.Kill)
|
||||
}
|
||||
proc.state = protos.ProcessState_Stopping
|
||||
proc.cmd.Wait()
|
||||
proc.cmd.Process.Release()
|
||||
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
|
||||
|
||||
proc.state = protos.ProcessState_Stopped
|
||||
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
|
||||
|
||||
if err := hc.launch(proc); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(restarts) == 0 {
|
||||
return errNoRunningProcess
|
||||
}
|
||||
|
||||
for _, proc := range restarts {
|
||||
if err := proc.cmd.Process.Signal(syscall.SIGTERM); err != nil {
|
||||
proc.cmd.Process.Signal(os.Kill)
|
||||
}
|
||||
proc.state = protos.ProcessState_Stopping
|
||||
}
|
||||
|
||||
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
|
||||
|
||||
for _, proc := range restarts {
|
||||
proc.cmd.Wait()
|
||||
proc.cmd.Process.Release()
|
||||
proc.state = protos.ProcessState_Stopped
|
||||
}
|
||||
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
|
||||
|
||||
for _, proc := range restarts {
|
||||
if err := hc.launch(proc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user