버전 비교 로직 제거
This commit is contained in:
@ -131,26 +131,37 @@ func unmarshal[T any](val *T, src map[string]string) {
|
|||||||
logger.Println("operation receive :", argval.Elem().Type().Name(), *val)
|
logger.Println("operation receive :", argval.Elem().Type().Name(), *val)
|
||||||
}
|
}
|
||||||
|
|
||||||
func gatherDeployedPrograms(storageRoot, name string) []*protos.VersionAndArgs {
|
type version_args_ts struct {
|
||||||
var rawvers []*protos.VersionAndArgs
|
*protos.VersionAndArgs
|
||||||
|
modTime time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func gatherDeployedPrograms(storageRoot, name string) (out []*protos.VersionAndArgs) {
|
||||||
|
var rawvers []version_args_ts
|
||||||
targetPath := path.Join(storageRoot, name)
|
targetPath := path.Join(storageRoot, name)
|
||||||
if vers, err := os.ReadDir(targetPath); err == nil {
|
if vers, err := os.ReadDir(targetPath); err == nil {
|
||||||
for _, ver := range vers {
|
for _, ver := range vers {
|
||||||
if ver.IsDir() {
|
if ver.IsDir() {
|
||||||
|
fi, _ := ver.Info()
|
||||||
args := lastExecutionArgs(path.Join(targetPath, ver.Name()))
|
args := lastExecutionArgs(path.Join(targetPath, ver.Name()))
|
||||||
rawvers = append(rawvers, &protos.VersionAndArgs{
|
rawvers = append(rawvers, version_args_ts{
|
||||||
Version: ver.Name(),
|
VersionAndArgs: &protos.VersionAndArgs{
|
||||||
Args: args,
|
Version: ver.Name(),
|
||||||
|
Args: args,
|
||||||
|
},
|
||||||
|
modTime: fi.ModTime(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort.Slice(rawvers, func(i, j int) bool {
|
sort.Slice(rawvers, func(i, j int) bool {
|
||||||
leftParsed := shared.ParseVersionString(rawvers[i].Version)
|
return rawvers[i].modTime.After(rawvers[j].modTime)
|
||||||
rightParsed := shared.ParseVersionString(rawvers[j].Version)
|
|
||||||
return shared.CompareVersionString(leftParsed, rightParsed) < 0
|
|
||||||
})
|
})
|
||||||
return rawvers
|
|
||||||
|
for _, v := range rawvers {
|
||||||
|
out = append(out, v.VersionAndArgs)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryRequest {
|
func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryRequest {
|
||||||
|
|||||||
@ -389,16 +389,6 @@ func (hc *houstonClient) launch(meta *procmeta) error {
|
|||||||
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 {
|
||||||
if req.Version == "latest" {
|
|
||||||
// 최신 버전을 찾음
|
|
||||||
latest, err := shared.FindLastestVersion(hc.config.StorageRoot, req.Name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Version = latest
|
|
||||||
}
|
|
||||||
|
|
||||||
meta := prepareProcessLaunch(hc.config.StorageRoot, req)
|
meta := prepareProcessLaunch(hc.config.StorageRoot, req)
|
||||||
if meta == nil {
|
if meta == nil {
|
||||||
return errPrepareprocessLaunchFailed
|
return errPrepareprocessLaunchFailed
|
||||||
@ -433,16 +423,6 @@ func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest, op p
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (hc *houstonClient) stopChildProcess(req *shared.StopProcessRequest, op protos.OperationClient) error {
|
func (hc *houstonClient) stopChildProcess(req *shared.StopProcessRequest, 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
|
|
||||||
}
|
|
||||||
|
|
||||||
killer := func(proc *procmeta) {
|
killer := func(proc *procmeta) {
|
||||||
proc.setState(protos.ProcessState_Stopping)
|
proc.setState(protos.ProcessState_Stopping)
|
||||||
if err := proc.cmd.Process.Signal(syscall.SIGTERM); err != nil {
|
if err := proc.cmd.Process.Signal(syscall.SIGTERM); err != nil {
|
||||||
@ -509,16 +489,6 @@ func (hc *houstonClient) restartChildProcess(req *shared.RestartProcessRequest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (hc *houstonClient) uploadFiles(req *shared.UploadRequest) error {
|
func (hc *houstonClient) uploadFiles(req *shared.UploadRequest) error {
|
||||||
if req.Version == "latest" {
|
|
||||||
// 최신 버전을 찾음
|
|
||||||
latest, err := shared.FindLastestVersion(hc.config.StorageRoot, req.Name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Version = latest
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Println("uploadFiles req :", *req)
|
logger.Println("uploadFiles req :", *req)
|
||||||
for _, child := range hc.childProcs {
|
for _, child := range hc.childProcs {
|
||||||
if child.version == req.Version && child.name == req.Name {
|
if child.version == req.Version && child.name == req.Name {
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -11,7 +11,7 @@ require (
|
|||||||
golang.org/x/text v0.10.0
|
golang.org/x/text v0.10.0
|
||||||
google.golang.org/grpc v1.56.0
|
google.golang.org/grpc v1.56.0
|
||||||
google.golang.org/protobuf v1.31.0
|
google.golang.org/protobuf v1.31.0
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20240122081445-b100148f54a3
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20240204120348-2fef6d4064b0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
13
go.sum
13
go.sum
@ -51,11 +51,8 @@ github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973/go.mod h1:PoK3ejP
|
|||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||||
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
||||||
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
|
||||||
github.com/jsimonetti/rtnetlink v1.3.2 h1:dcn0uWkfxycEEyNy0IGfx3GrhQ38LH7odjxAghimsVI=
|
github.com/jsimonetti/rtnetlink v1.3.2 h1:dcn0uWkfxycEEyNy0IGfx3GrhQ38LH7odjxAghimsVI=
|
||||||
github.com/jsimonetti/rtnetlink v1.3.2/go.mod h1:BBu4jZCpTjP6Gk0/wfrO8qcqymnN3g0hoFqObRmUo6U=
|
github.com/jsimonetti/rtnetlink v1.3.2/go.mod h1:BBu4jZCpTjP6Gk0/wfrO8qcqymnN3g0hoFqObRmUo6U=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
|
||||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
@ -79,11 +76,8 @@ github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U
|
|||||||
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
|
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
|
||||||
github.com/mdlayher/wifi v0.0.0-20220330172155-a44c70b6d3c8 h1:/HCRFfpoICSWHvNrJ356VO4opd9dg/LaU7m8Tzdf39c=
|
github.com/mdlayher/wifi v0.0.0-20220330172155-a44c70b6d3c8 h1:/HCRFfpoICSWHvNrJ356VO4opd9dg/LaU7m8Tzdf39c=
|
||||||
github.com/mdlayher/wifi v0.0.0-20220330172155-a44c70b6d3c8/go.mod h1:IqdtNfemiXr50M8tnxLWSFdZKZ9vcI1Mgt0oTrCIS7A=
|
github.com/mdlayher/wifi v0.0.0-20220330172155-a44c70b6d3c8/go.mod h1:IqdtNfemiXr50M8tnxLWSFdZKZ9vcI1Mgt0oTrCIS7A=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
|
||||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
|
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
|
||||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
|
||||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||||
@ -174,13 +168,10 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
|
|||||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
|
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
|
||||||
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
|
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20231202113043-3e1febab564a h1:o6Xt5QH4C/83DS8GRhNHGbJPXD0Fr3IFB1KptaXjgwY=
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20240204120348-2fef6d4064b0 h1:HBEVd4n9080Lz5R3S00PBqK1c6xI2m3eACcQa7Q2a8g=
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20231202113043-3e1febab564a/go.mod h1:Gb418rT96M3K7L/XMPzp8IJj4UXVunq7dZzrxsMBz/8=
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20240204120348-2fef6d4064b0/go.mod h1:Gb418rT96M3K7L/XMPzp8IJj4UXVunq7dZzrxsMBz/8=
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20240122081445-b100148f54a3 h1:gf07Uv+kkrGj2uI4gEY3lEDdxrsoAoESUG0YS0guYjg=
|
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20240122081445-b100148f54a3/go.mod h1:Gb418rT96M3K7L/XMPzp8IJj4UXVunq7dZzrxsMBz/8=
|
|
||||||
|
|||||||
@ -499,10 +499,6 @@ func (h *houstonHandler) GetLogFileLinks(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if version == "latest" {
|
|
||||||
version, _ = shared.FindLastestVersion(h.downloadPath, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
root := path.Join(h.downloadPath, name, version)
|
root := path.Join(h.downloadPath, name, version)
|
||||||
logfiles, err := os.ReadDir(root)
|
logfiles, err := os.ReadDir(root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -1,12 +1,5 @@
|
|||||||
package shared
|
package shared
|
||||||
|
|
||||||
import (
|
|
||||||
"io/fs"
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Operation string
|
type Operation string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -58,62 +51,3 @@ type UploadRequest struct {
|
|||||||
Filter string
|
Filter string
|
||||||
DeleteAfterUploaded string // true, false
|
DeleteAfterUploaded string // true, false
|
||||||
}
|
}
|
||||||
|
|
||||||
type ParsedVersionString = []string
|
|
||||||
|
|
||||||
func ParseVersionString(ver string) ParsedVersionString {
|
|
||||||
return strings.Split(ver, ".")
|
|
||||||
}
|
|
||||||
|
|
||||||
func CompareVersionString(lhs, rhs ParsedVersionString) int {
|
|
||||||
minlen := len(lhs)
|
|
||||||
if minlen > len(rhs) {
|
|
||||||
minlen = len(rhs)
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < minlen; i++ {
|
|
||||||
if len(lhs[i]) < len(rhs[i]) {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(lhs[i]) > len(rhs[i]) {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if lhs[i] < rhs[i] {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
if lhs[i] > rhs[i] {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return len(lhs) - len(rhs)
|
|
||||||
}
|
|
||||||
|
|
||||||
func FindLastestVersion(storageRoot, name string) (string, error) {
|
|
||||||
// 최신 버전을 찾음
|
|
||||||
targetPath := path.Join(storageRoot, name)
|
|
||||||
entries, err := os.ReadDir(targetPath)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if len(entries) == 0 {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return strings.Join(latest, "."), nil
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user