From 432cc68024e06bb288bda9c41c8c0fb3699af9f1 Mon Sep 17 00:00:00 2001 From: mountain Date: Wed, 8 Nov 2023 09:21:09 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A0=88=EB=8C=80=20=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=EB=A1=9C=20child=20process=20=EC=8B=A4=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/operation.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/client/operation.go b/client/operation.go index d0992ab..4e2a822 100644 --- a/client/operation.go +++ b/client/operation.go @@ -172,10 +172,11 @@ func prepareProcessLaunch(storageRoot string, req *shared.StartProcessRequest) * fi, err := os.Stat(verpath) if err == nil && fi.IsDir() { - req.Args[0] = "./" + path.Clean(strings.TrimPrefix(req.Args[0], "/")) - os.Chmod(path.Join(verpath, req.Args[0]), 0777) + exefile := "./" + path.Clean(strings.TrimPrefix(req.Args[0], "/")) + os.Chmod(path.Join(verpath, exefile), 0777) - cmd := exec.Command(req.Args[0], req.Args[1:]...) + exef, _ := os.Executable() + cmd := exec.Command(path.Join(path.Dir(exef), verpath, exefile), req.Args[1:]...) cmd.Dir = verpath stdin, _ := cmd.StdinPipe() @@ -312,17 +313,19 @@ func (hc *houstonClient) launch(meta *procmeta) error { go stdReader(stderr) go stdReader(stdout) + logger.Println("startChildProcess :", meta.cmd.Args) + err = meta.cmd.Start() if err == nil { meta.state = protos.ProcessState_Running } + return err } var errPrepareprocessLaunchFailed = errors.New("prepareProcessLaunch failed") func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest, op protos.OperationClient) error { - logger.Println("startChildProcess :", *req) if req.Version == "latest" { // 최신 버전을 찾음 latest, err := shared.FindLastestVersion(hc.config.StorageRoot, req.Name) @@ -351,12 +354,12 @@ func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest, op p if argfile, err := os.Create(path.Join(hc.config.StorageRoot, req.Name, "@args")); err == nil { enc := json.NewEncoder(argfile) - enc.Encode(meta.cmd.Args) + enc.Encode(req.Args) argfile.Close() } if argfile, err := os.Create(path.Join(hc.config.StorageRoot, req.Name, req.Version, "@args")); err == nil { enc := json.NewEncoder(argfile) - enc.Encode(meta.cmd.Args) + enc.Encode(req.Args) argfile.Close() }