From ac7902e7ae3d192f7f0ffb5c1508e2adf89ec728 Mon Sep 17 00:00:00 2001 From: mountain Date: Mon, 22 May 2023 15:39:08 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EB=B2=84=EC=A0=84=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/operation.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/client/operation.go b/client/operation.go index 7881eab..2cae0cf 100644 --- a/client/operation.go +++ b/client/operation.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "io" + "io/fs" "net/http" "os" "os/exec" @@ -84,9 +85,15 @@ func findLastestVersion(root string) (string, error) { if len(entries) == 0 { return "", nil } - latest := parseVersionString(entries[0].Name()) - for i := 1; i < len(entries); i++ { - next := parseVersionString(entries[i].Name()) + var dironly []fs.DirEntry + for _, ent := range entries { + if ent.IsDir() { + dironly = append(dironly, ent) + } + } + latest := parseVersionString(dironly[0].Name()) + for i := 1; i < len(dironly); i++ { + next := parseVersionString(dironly[i].Name()) if compareVersionString(latest, next) < 0 { latest = next } @@ -153,8 +160,7 @@ func (meta *procmeta) launch(args []string, exitChan chan<- *exec.Cmd) error { break } errfile.Write(buff[:size]) - new := atomic.AddInt32(&meta.stderrSize, int32(size)) - logger.Println("stderrSize :", new) + atomic.AddInt32(&meta.stderrSize, int32(size)) } }() @@ -173,8 +179,7 @@ func (meta *procmeta) launch(args []string, exitChan chan<- *exec.Cmd) error { break } outfile.Write(buff[:size]) - new := atomic.AddInt32(&meta.stdoutSize, int32(size)) - logger.Println("stdoutSize :", new) + atomic.AddInt32(&meta.stdoutSize, int32(size)) } }() @@ -192,6 +197,7 @@ func (meta *procmeta) launch(args []string, exitChan chan<- *exec.Cmd) error { } func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest) error { + logger.Println("startChildProcess :", *req) if req.Version == "latest" { // 최신 버전을 찾음 latest, err := findLastestVersion(path.Join("./", req.Name)) @@ -211,6 +217,7 @@ func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest) erro verpath := path.Join("./", req.Name, req.Version) fi, err := os.Stat(verpath) if err == nil && fi.IsDir() { + logger.Println("path found :", verpath) // Define regular expression re := regexp.MustCompile(`[^\s"']+|"([^"]*)"|'([^']*)`) From 0f7b5c22fc010ce29f90864511da4c1e48197ec8 Mon Sep 17 00:00:00 2001 From: mountain Date: Mon, 22 May 2023 15:39:19 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EC=A4=91=EC=A7=80=EB=90=9C=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EC=84=B8=EC=8A=A4=EB=8A=94=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/client.go b/client/client.go index db3c02c..e70efa0 100644 --- a/client/client.go +++ b/client/client.go @@ -202,13 +202,16 @@ func NewClient(grpcAddr string, httpAddr string) (HoustonClient, error) { return case exited := <-exitChan: + var newprocs []*procmeta for _, proc := range hc.childProcs { if proc.cmd == exited && proc.state != protos.ProcessState_Stopped { proc.state = protos.ProcessState_Stopped - op.Refresh(ctx, hc.makeOperationQueryRequest()) - break + } else { + newprocs = append(newprocs, proc) } } + hc.childProcs = newprocs + op.Refresh(ctx, hc.makeOperationQueryRequest()) case resp := <-operationChan: switch shared.Operation(resp.Operation) {