절대 경로로 child process 실행
This commit is contained in:
@ -172,10 +172,11 @@ func prepareProcessLaunch(storageRoot string, req *shared.StartProcessRequest) *
|
|||||||
fi, err := os.Stat(verpath)
|
fi, err := os.Stat(verpath)
|
||||||
|
|
||||||
if err == nil && fi.IsDir() {
|
if err == nil && fi.IsDir() {
|
||||||
req.Args[0] = "./" + path.Clean(strings.TrimPrefix(req.Args[0], "/"))
|
exefile := "./" + path.Clean(strings.TrimPrefix(req.Args[0], "/"))
|
||||||
os.Chmod(path.Join(verpath, req.Args[0]), 0777)
|
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
|
cmd.Dir = verpath
|
||||||
stdin, _ := cmd.StdinPipe()
|
stdin, _ := cmd.StdinPipe()
|
||||||
|
|
||||||
@ -312,17 +313,19 @@ func (hc *houstonClient) launch(meta *procmeta) error {
|
|||||||
go stdReader(stderr)
|
go stdReader(stderr)
|
||||||
go stdReader(stdout)
|
go stdReader(stdout)
|
||||||
|
|
||||||
|
logger.Println("startChildProcess :", meta.cmd.Args)
|
||||||
|
|
||||||
err = meta.cmd.Start()
|
err = meta.cmd.Start()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
meta.state = protos.ProcessState_Running
|
meta.state = protos.ProcessState_Running
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var errPrepareprocessLaunchFailed = errors.New("prepareProcessLaunch failed")
|
var errPrepareprocessLaunchFailed = errors.New("prepareProcessLaunch failed")
|
||||||
|
|
||||||
func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest, op protos.OperationClient) error {
|
func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest, op protos.OperationClient) error {
|
||||||
logger.Println("startChildProcess :", *req)
|
|
||||||
if req.Version == "latest" {
|
if req.Version == "latest" {
|
||||||
// 최신 버전을 찾음
|
// 최신 버전을 찾음
|
||||||
latest, err := shared.FindLastestVersion(hc.config.StorageRoot, req.Name)
|
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 {
|
if argfile, err := os.Create(path.Join(hc.config.StorageRoot, req.Name, "@args")); err == nil {
|
||||||
enc := json.NewEncoder(argfile)
|
enc := json.NewEncoder(argfile)
|
||||||
enc.Encode(meta.cmd.Args)
|
enc.Encode(req.Args)
|
||||||
argfile.Close()
|
argfile.Close()
|
||||||
}
|
}
|
||||||
if argfile, err := os.Create(path.Join(hc.config.StorageRoot, req.Name, req.Version, "@args")); err == nil {
|
if argfile, err := os.Create(path.Join(hc.config.StorageRoot, req.Name, req.Version, "@args")); err == nil {
|
||||||
enc := json.NewEncoder(argfile)
|
enc := json.NewEncoder(argfile)
|
||||||
enc.Encode(meta.cmd.Args)
|
enc.Encode(req.Args)
|
||||||
argfile.Close()
|
argfile.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user