Compare commits

...

91 Commits

Author SHA1 Message Date
31d77efe84 Merge branch 'master' into kd-live 2023-09-05 17:16:43 +09:00
3ace1be27a stdout을 dev/null로 redirect 2023-09-05 17:16:05 +09:00
3fccae1ef5 Merge branch 'master' into kd-live 2023-07-03 14:32:09 +09:00
3dc121bc71 버전에 태그가 일찍 붙는 문제 수정 2023-07-03 14:31:55 +09:00
706339a386 Merge branch 'master' into kd-live 2023-07-03 14:18:20 +09:00
849973c449 서비스 자체 태그도 넘겨줌 2023-07-03 14:18:11 +09:00
759dcaf00b Merge branch 'master' into kd-live 2023-07-03 14:12:35 +09:00
d1a192159b 서비스 태그를 하위 버전에도 붙여줌 2023-07-03 14:12:21 +09:00
db4769687c Merge branch 'master' into kd-live 2023-07-03 14:08:46 +09:00
7a5696961f 버전에 태그를 붙임 2023-07-03 14:08:28 +09:00
7418d847b7 Merge branch 'master' into kd-live 2023-07-03 11:44:00 +09:00
4d9a25dd6b 클라이언트에서는 태그를 없애고 서버에서만 관리 2023-07-03 11:34:21 +09:00
b057730ad5 Merge branch 'master' into kd-live 2023-07-03 10:54:27 +09:00
9bd09509c8 reaonly 대신 tag로 교체 2023-07-03 10:54:13 +09:00
d526a923ca Merge branch 'master' into kd-live 2023-06-30 16:48:51 +09:00
1b57e9f87e 업로드 된 로그 파일은 지우되, 최신도 같이 지워지던 문제 수정 2023-06-30 16:48:13 +09:00
30412bce70 Merge branch 'master' into kd-live 2023-06-30 16:38:13 +09:00
4667d351a8 업로드한 로그 제거 안함 2023-06-30 16:38:01 +09:00
20dc204cb1 Merge branch 'master' into kd-live 2023-06-30 15:51:47 +09:00
571f0d76df 업로드한 로그도 제거하지 말자 2023-06-30 15:51:03 +09:00
025e583f12 Merge branch 'master' into kd-live 2023-06-29 14:13:17 +09:00
15dd1e544c 하위 폴더 복사 누락 수정 2023-06-29 14:13:04 +09:00
b3ed139431 Merge branch 'master' into kd-live 2023-06-29 12:24:22 +09:00
45ab15d345 gracefulstop 말고 바로 stop 2023-06-29 12:24:13 +09:00
c0a0f88220 Merge branch 'master' into kd-live 2023-06-29 12:05:22 +09:00
02db65e06f houston 버전 관리 2023-06-29 12:05:11 +09:00
ed4ca6cfed Merge branch 'master' into kd-live 2023-06-29 11:11:35 +09:00
a8821b694b 버전 파일 경로 오류 수정 2023-06-29 11:11:23 +09:00
7c54fda9a2 Merge branch 'master' into kd-live 2023-06-29 11:00:49 +09:00
5429d3d90f houstonClient도 버전 관리 2023-06-29 11:00:26 +09:00
77174ccef4 Merge branch 'master' into kd-live 2023-06-29 10:20:09 +09:00
cf46888b6a houstonClient 종료시 houstonServer도 종료 2023-06-29 10:19:57 +09:00
642d53fbba Merge branch 'master' into kd-live 2023-06-28 18:29:20 +09:00
6a35d7b1fe 프로세스 구동중인지 검출하는 로직 변경 2023-06-28 18:29:12 +09:00
361ff4bb3a Merge branch 'master' into kd-live 2023-06-28 18:23:08 +09:00
d04dd5b05d 로그 더 추가 2023-06-28 18:22:50 +09:00
942875071f Merge branch 'master' into kd-live 2023-06-28 18:15:25 +09:00
d3442be5dc 로그 추가 2023-06-28 18:15:13 +09:00
bff9548dab Merge branch 'master' into kd-live 2023-06-28 18:01:53 +09:00
06bc095ea4 프로세스 종료 판별 로직 수정 2023-06-28 18:00:51 +09:00
e5b7a7b02b Merge branch 'master' into kd-live 2023-06-27 20:05:32 +09:00
da47d7c587 httpwriter tracker 일단 다시 제거 2023-06-27 20:05:23 +09:00
3f2c82251b Merge branch 'master' into kd-live 2023-06-27 11:55:39 +09:00
d464812cf8 config 다운로드 경로 수정 2023-06-27 11:55:24 +09:00
fdb0a7baa5 Merge branch 'master' into kd-live 2023-06-27 11:17:28 +09:00
fa8b78efed restart 로직 변경 2023-06-27 11:17:16 +09:00
cf033b6107 Merge branch 'master' into kd-live 2023-06-27 11:02:28 +09:00
9b0aa4d640 인덱스 버그 수정 2023-06-27 11:02:19 +09:00
96a0b43e3f Merge branch 'master' into kd-live 2023-06-27 10:53:27 +09:00
cacbc1008a operation argument에 []string 지원 2023-06-27 10:53:14 +09:00
6185d055ef Merge branch 'master' into kd-live 2023-06-27 10:06:42 +09:00
6d319f2fa1 logapicall 플래그 추가 2023-06-27 10:06:26 +09:00
b2aae5a38e Merge branch 'master' into kd-live 2023-06-27 09:45:10 +09:00
01b4782e78 프로세스 재시작 지원 2023-06-27 09:44:56 +09:00
52491aff17 Merge branch 'master' into kd-live 2023-06-27 00:03:55 +09:00
72e94ccfc3 noauth 처리 2023-06-27 00:03:43 +09:00
8a1bcdc840 Merge branch 'master' into kd-live 2023-06-26 23:24:59 +09:00
d17c53c79c 로그 추가 2023-06-26 23:24:49 +09:00
8bb1e4d0a2 Merge branch 'master' into kd-live 2023-06-26 22:38:56 +09:00
9590de2e00 프로세스 종료 대기 로직 수정 2023-06-26 22:38:29 +09:00
d48afc61af Merge branch 'master' into kd-live 2023-06-26 19:20:06 +09:00
58897522a7 config 파일이 없어도 괜춘 2023-06-26 19:19:58 +09:00
1b6c4edaff Merge branch 'master' into kd-live 2023-06-26 11:27:10 +09:00
06b390815c 프로세스 재시작 요청 추가 2023-06-26 11:26:57 +09:00
95bc4d8db3 Merge branch 'master' into kd-live 2023-06-22 20:39:55 +09:00
3d3020f827 폴더 다시 조정 2023-06-22 20:39:38 +09:00
6a316afd90 Merge branch 'master' into kd-live 2023-06-22 20:35:51 +09:00
9947835ba1 deploys, downloads 경로 변경 2023-06-22 20:35:35 +09:00
bbe340f559 kd live는 go 1.18 2023-06-22 20:25:17 +09:00
30ff0a4b27 deploy source에 다운로드 경로를 보내줌 2023-06-22 20:24:59 +09:00
c98023cc8b 서버와 클라이언트 동시에 구동하는 옵션 추가 2023-06-22 17:16:09 +09:00
3278bca32f 하드코딩된 폴더들 const로 뺌 2023-06-22 17:15:56 +09:00
bdc3e19718 flag를 flagx로 교체 2023-06-21 14:35:27 +09:00
61a98247d8 따옴표 문제 수정 2023-06-15 16:25:55 +09:00
3f2ea5cee3 자식 프로세스 비정상종료시 처리 2023-06-15 11:24:02 +09:00
a8548fffe2 cors cjfl 2023-06-14 15:51:54 +09:00
f58db1ec09 json 소문자로 변경 2023-06-14 15:33:44 +09:00
1c1f9f748a 안쓰는 필드 제거 2023-06-14 15:30:01 +09:00
279c9f47f0 client도 storageroot지원 2023-06-14 14:16:47 +09:00
46aedbe767 모듈 업데이트 2023-06-14 01:50:48 +09:00
96ee2a4627 자동 재접속 2023-06-14 01:50:40 +09:00
2e4b7811db replace에 다음 실행 파라미터도 넘길 수 있음 2023-06-14 01:50:25 +09:00
3add5d9355 로거 되돌림 2023-06-14 00:13:51 +09:00
20b2df1fc5 로그 정리 2023-06-13 23:54:32 +09:00
4cec01609a 로거 정리 2023-06-13 23:49:37 +09:00
43da9424f0 다운로드 링크 수정 2023-06-13 23:49:25 +09:00
c4c0f86947 로거 정리 2023-06-13 23:49:14 +09:00
838b3a2194 unzip 버그 수정 - 백슬래시 처리 추가 2023-06-13 23:48:51 +09:00
93c13ba92f houston package 생성 스크립트 추가 2023-06-13 20:13:03 +09:00
ed5b4c06e9 ignore 업데이트 2023-06-13 20:12:37 +09:00
c1847ee3e1 파일에 직접 로깅하는 로거로 교체 2023-06-13 20:03:10 +09:00
19 changed files with 660 additions and 393 deletions

4
.gitignore vendored
View File

@ -1,2 +1,6 @@
*.log
*.exe
houston
houston.zip
config.json
.vscode/

21
.vscode/launch.json vendored
View File

@ -1,21 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "houston",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"env": {
},
"args" : [
"-port=8080",
"-client"
]
}
]
}

View File

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"os"
"os/exec"
"os/signal"
@ -14,6 +15,7 @@ import (
"reflect"
"sort"
"strconv"
"strings"
"sync"
"sync/atomic"
"syscall"
@ -31,6 +33,7 @@ import (
type clientConfig struct {
GrpcAddress string `json:"grpc_server_address"`
HttpAddress string `json:"http_server_address"`
StorageRoot string `json:"storage_path"`
}
func loadClientConfig() (clientConfig, error) {
@ -103,7 +106,6 @@ type procmeta struct {
}
type houstonClient struct {
client *grpc.ClientConn
childProcs []*procmeta
extraMetrics unsafe.Pointer // map[string]float32
deploys map[string][]*protos.VersionAndArgs
@ -111,13 +113,17 @@ type houstonClient struct {
ctx context.Context
operationChan chan *protos.OperationQueryResponse
exitChan chan *exec.Cmd
httpAddr string
clientChan chan *grpc.ClientConn
timestamp string
wg sync.WaitGroup
config clientConfig
version string
standalone bool
}
func unmarshal[T any](val *T, src map[string]string) {
argval := reflect.ValueOf(val)
logger.Println("operation receive :", argval.Type().Name(), src)
for i := 0; i < argval.Elem().Type().NumField(); i++ {
if !argval.Elem().Type().Field(i).IsExported() {
continue
@ -126,18 +132,22 @@ func unmarshal[T any](val *T, src map[string]string) {
if argval.Elem().Field(i).CanInt() {
num, _ := strconv.ParseInt(arg, 10, 0)
argval.Elem().Field(i).SetInt(num)
} else if argval.Elem().Field(i).Kind() == reflect.Array || argval.Elem().Field(i).Kind() == reflect.Slice {
conv := strings.Split(arg, "\n")
argval.Elem().Field(i).Set(reflect.ValueOf(conv))
} else {
argval.Elem().Field(i).SetString(arg)
}
}
}
func gatherDeployedPrograms(name string) []*protos.VersionAndArgs {
func gatherDeployedPrograms(storageRoot, name string) []*protos.VersionAndArgs {
var rawvers []*protos.VersionAndArgs
if vers, err := os.ReadDir(name); err == nil {
targetPath := path.Join(storageRoot, name)
if vers, err := os.ReadDir(targetPath); err == nil {
for _, ver := range vers {
if ver.IsDir() {
args := lastExecutionArgs(path.Join(name, ver.Name()))
args := lastExecutionArgs(path.Join(targetPath, ver.Name()))
rawvers = append(rawvers, &protos.VersionAndArgs{
Version: ver.Name(),
Args: args,
@ -154,8 +164,33 @@ func gatherDeployedPrograms(name string) []*protos.VersionAndArgs {
}
func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryRequest {
hn, _ := os.Hostname()
procs := make([]*protos.ProcessDescription, 0, len(hc.childProcs))
var procs []*protos.ProcessDescription
var deploys []*protos.DeployedVersions
var selfname string
var selfargs []string
if hc.standalone {
selfname = path.Base(os.Args[0])
selfargs = os.Args[1:]
} else {
selfname = "houston"
selfargs = []string{}
}
procs = append(procs, &protos.ProcessDescription{
Name: selfname,
Args: selfargs,
Version: hc.version,
State: protos.ProcessState_Running,
Pid: int32(os.Getpid()),
})
deploys = append(deploys, &protos.DeployedVersions{
Name: selfname,
Versions: []*protos.VersionAndArgs{
{Version: hc.version, Args: selfargs},
},
})
for _, child := range hc.childProcs {
procs = append(procs, &protos.ProcessDescription{
Name: child.name,
@ -166,7 +201,6 @@ func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryReque
})
}
var deploys []*protos.DeployedVersions
for name, prog := range hc.deploys {
deploys = append(deploys, &protos.DeployedVersions{
Name: name,
@ -174,6 +208,7 @@ func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryReque
})
}
hn, _ := os.Hostname()
return &protos.OperationQueryRequest{
Hostname: hn,
Procs: procs,
@ -181,7 +216,7 @@ func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryReque
}
}
func NewClient() (HoustonClient, error) {
func NewClient(standalone bool) (HoustonClient, error) {
clientConfig, err := loadClientConfig()
if err != nil {
return nil, err
@ -195,22 +230,6 @@ func NewClient() (HoustonClient, error) {
return nil, errors.New("client.http_server_address is missing")
}
var client *grpc.ClientConn
for {
logger.Println("grpc.DialContext :", clientConfig.GrpcAddress)
dialContext, cancelDial := context.WithTimeout(context.Background(), 15*time.Second)
client, err = grpc.DialContext(dialContext, clientConfig.GrpcAddress, grpc.WithBlock(), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err == nil {
cancelDial()
break
}
cancelDial()
logger.Println("grpc.DialContext failed :", err)
time.Sleep(5 * time.Second)
}
logger.Println("grpc.DialContext succeeded")
exefile, err := os.Executable()
if err != nil {
return nil, err
@ -221,24 +240,44 @@ func NewClient() (HoustonClient, error) {
return nil, err
}
sp, err := os.Stat(clientConfig.StorageRoot)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
err = os.MkdirAll(clientConfig.StorageRoot, 0775)
}
} else if !sp.IsDir() {
err = errors.New(clientConfig.StorageRoot + " is not directory")
}
if err != nil {
return nil, err
}
deploys := make(map[string][]*protos.VersionAndArgs)
if dirs, err := os.ReadDir("./"); err == nil {
if dirs, err := os.ReadDir(clientConfig.StorageRoot); err == nil {
for _, dir := range dirs {
if dir.IsDir() {
flagf := path.Join(dir.Name(), "@houston")
flagf := path.Join(clientConfig.StorageRoot, dir.Name(), "@houston")
if _, err := os.Stat(flagf); !os.IsNotExist(err) {
deploys[dir.Name()] = gatherDeployedPrograms(dir.Name())
deploys[dir.Name()] = gatherDeployedPrograms(clientConfig.StorageRoot, dir.Name())
}
}
}
}
ver, _ := os.ReadFile("@version")
if len(ver) == 0 {
ver = []byte("0.0.0")
}
hc := &houstonClient{
client: client,
config: clientConfig,
clientChan: make(chan *grpc.ClientConn),
extraMetrics: unsafe.Pointer(&map[string]float32{}),
deploys: deploys,
httpAddr: clientConfig.HttpAddress,
timestamp: exefi.ModTime().String(),
version: string(ver),
standalone: standalone,
}
ctx, cancel := context.WithCancel(context.Background())
@ -251,7 +290,7 @@ func NewClient() (HoustonClient, error) {
defer hc.wg.Done()
// 메인 operator
op := protos.NewOperationClient(hc.client)
var op protos.OperationClient
myname, _ := os.Executable()
myname = path.Base(filepath.ToSlash(myname))
if len(path.Ext(myname)) > 0 {
@ -266,11 +305,30 @@ func NewClient() (HoustonClient, error) {
case <-ctx.Done():
return
case newClient := <-hc.clientChan:
op = protos.NewOperationClient(newClient)
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
if proc.cmd == exited {
if proc.state == protos.ProcessState_Running || proc.state == protos.ProcessState_Restart {
go func(proc *procmeta) {
if err := proc.cmd.Process.Signal(syscall.SIGTERM); err != nil {
proc.cmd.Process.Signal(os.Kill)
}
proc.cmd.Wait()
proc.cmd.Process.Release()
if proc.state == protos.ProcessState_Restart {
hc.startChildProcess(&shared.StartProcessRequest{
Version: proc.version,
Name: proc.name,
Args: proc.cmd.Args,
}, op)
}
}(proc)
}
} else {
newprocs = append(newprocs, proc)
}
@ -283,8 +341,6 @@ func NewClient() (HoustonClient, error) {
case shared.Deploy:
var dr shared.DeployRequest
unmarshal(&dr, resp.Args)
logger.Println(dr.Name, myname)
if dr.Name == myname {
if srcdir, replacer, err := hc.prepareUpdateSelf(&dr); err == nil {
args := []string{
@ -304,7 +360,7 @@ func NewClient() (HoustonClient, error) {
}
} else {
if err := hc.deploy(&dr); err == nil {
prog := gatherDeployedPrograms(dr.Name)
prog := gatherDeployedPrograms(hc.config.StorageRoot, dr.Name)
hc.deploys[dr.Name] = prog
op.Refresh(ctx, hc.makeOperationQueryRequest())
} else {
@ -317,7 +373,7 @@ func NewClient() (HoustonClient, error) {
unmarshal(&wr, resp.Args)
err := hc.withdraw(&wr)
if err == nil {
prog := gatherDeployedPrograms(wr.Name)
prog := gatherDeployedPrograms(hc.config.StorageRoot, wr.Name)
if len(prog) == 0 {
delete(hc.deploys, wr.Name)
} else {
@ -331,21 +387,21 @@ func NewClient() (HoustonClient, error) {
case shared.Start:
var sr shared.StartProcessRequest
unmarshal(&sr, resp.Args)
if err := hc.startChildProcess(&sr); err != nil {
if err := hc.startChildProcess(&sr, op); err != nil {
logger.Println(err)
}
case shared.Stop:
var sr shared.StopProcessRequest
unmarshal(&sr, resp.Args)
if err := hc.stopChildProcess(&sr); err != nil {
if err := hc.stopChildProcess(&sr, op); err != nil {
logger.Println(err)
}
case shared.Restart:
var rr shared.RestartProcessRequest
unmarshal(&rr, resp.Args)
if err := hc.restartChildProcess(&rr); err != nil {
if err := hc.restartChildProcess(&rr, op); err != nil {
logger.Println(err)
}
@ -382,6 +438,7 @@ func (hc *houstonClient) Start() {
for _, proc := range hc.childProcs {
proc.cmd.Wait()
proc.cmd.Process.Release()
}
}()
@ -394,15 +451,39 @@ func (hc *houstonClient) Start() {
hc.shutdownFunc()
}()
var client *grpc.ClientConn
reconnCount := 0
time.Sleep(time.Second)
for {
select {
case <-hc.ctx.Done():
return
default:
err := hc.checkOperation()
if err != nil {
logger.Println("hc.checkUpdate failed :", err)
if client == nil {
if reconnCount == 0 {
logger.Println("grpc.DialContext :", hc.config.GrpcAddress)
}
reconnCount++
dialContext, cancelDial := context.WithTimeout(context.Background(), 15*time.Second)
client, _ = grpc.DialContext(dialContext, hc.config.GrpcAddress, grpc.WithBlock(), grpc.WithTransportCredentials(insecure.NewCredentials()))
cancelDial()
if client != nil {
reconnCount = 0
logger.Println("grpc.DialContext succeeded")
hc.clientChan <- client
}
}
if client != nil {
err := hc.checkOperation(client)
if err != nil {
logger.Println("hc.checkUpdate failed :", err)
client = nil
}
}
}
}
@ -412,15 +493,15 @@ func (hc *houstonClient) Shutdown() {
hc.shutdownFunc()
}
func (hc *houstonClient) checkOperation() error {
func (hc *houstonClient) checkOperation(client *grpc.ClientConn) error {
defer func() {
r := recover()
if r != nil {
logger.Error(r)
logger.Println(r)
}
}()
op := protos.NewOperationClient(hc.client)
op := protos.NewOperationClient(client)
cl, err := op.Query(hc.ctx, grpc.WaitForReady(true))
if err != nil {
return err
@ -438,7 +519,6 @@ func (hc *houstonClient) checkOperation() error {
cl.CloseSend()
return err
}
logger.Println(update)
hc.operationChan <- update
}
}

View File

@ -14,7 +14,6 @@ import (
"strings"
"repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/houston/shared"
"golang.org/x/text/encoding/korean"
@ -22,16 +21,22 @@ import (
"golang.org/x/text/transform"
)
func download(dir string, urlpath string, accessToken string) (string, error) {
func download(dir string, urlpath string, accessToken string) (target string, err error) {
logger.Println("start downloading", dir, urlpath)
defer func() {
if err != nil {
logger.Println("downloading failed :", err)
} else {
logger.Println("downloading succeeded")
}
}()
parsed, err := url.Parse(urlpath)
if err != nil {
return "", err
}
req, _ := http.NewRequest("GET", urlpath, nil)
if len(accessToken) > 0 {
req.Header.Add("Authorization", accessToken)
}
req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51")
resp, err := http.DefaultClient.Do(req)
if err != nil {
@ -77,10 +82,12 @@ func unzip(fname string) error {
name = f.Name
}
name = strings.ReplaceAll(name, `\`, "/")
filePath := path.Join(verpath, name)
if f.FileInfo().IsDir() {
os.MkdirAll(filePath, 0775)
if f.FileInfo().IsDir() || strings.HasSuffix(f.FileInfo().Name(), `\`) {
if err = os.MkdirAll(filePath, 0775); err != nil {
return err
}
continue
}
@ -157,8 +164,9 @@ func (hc *houstonClient) prepareDeploy(name string, version string) (destPath st
// houston관리용임을 표시하기 위해 더미파일 생성
defer func() {
var flagf *os.File
if _, err := os.Stat(path.Join(name, "@houston")); os.IsNotExist(err) {
flagf, err = os.Create(path.Join(name, "@houston"))
markerPath := path.Join(hc.config.StorageRoot, name, "@houston")
if _, err := os.Stat(markerPath); os.IsNotExist(err) {
flagf, err = os.Create(markerPath)
if err != nil {
return
}
@ -167,7 +175,7 @@ func (hc *houstonClient) prepareDeploy(name string, version string) (destPath st
}
}()
verpath := path.Join(name, version)
verpath := path.Join(hc.config.StorageRoot, name, version)
if _, err := os.Stat(verpath); os.IsNotExist(err) {
// 없네? 만들면 된다.
err = os.MkdirAll(verpath, 0775)
@ -190,7 +198,7 @@ func (hc *houstonClient) prepareDeploy(name string, version string) (destPath st
func (hc *houstonClient) makeDownloadUrl(rel string) string {
out := rel
if !strings.HasPrefix(out, "http") {
tks := strings.SplitN(hc.httpAddr, "://", 2)
tks := strings.SplitN(hc.config.HttpAddress, "://", 2)
out = fmt.Sprintf("%s://%s", tks[0], path.Join(tks[1], rel))
}
return out
@ -256,12 +264,22 @@ func (hc *houstonClient) prepareUpdateSelf(req *shared.DeployRequest) (srcdir st
return "", "", err
}
// houston version 파일
err = os.WriteFile(path.Join(path.Dir(fname), "@version"), []byte(req.Version), 0644)
if err != nil {
return "", "", err
}
selfname, _ := os.Executable()
srcreplacer := path.Join(path.Dir(fname), "replacer") + path.Ext(selfname)
replacer = "replacer" + path.Ext(selfname)
replacer = "./" + filepath.ToSlash("replacer"+path.Ext(selfname))
err = copy(srcreplacer, replacer)
if err == nil {
err = os.Chmod(replacer, 0775)
}
// replacer먼저 가져옴
return filepath.ToSlash(tempdir), filepath.ToSlash(replacer), copy(srcreplacer, replacer)
return filepath.ToSlash(tempdir), replacer, err
}
func (hc *houstonClient) deploy(req *shared.DeployRequest) error {
@ -271,7 +289,6 @@ func (hc *houstonClient) deploy(req *shared.DeployRequest) error {
return err
}
logger.Println("start downloading", req.Url)
// verpath에 배포 시작
fname, err := download(root, hc.makeDownloadUrl(req.Url), req.AccessToken)
if err != nil {
@ -285,7 +302,7 @@ func (hc *houstonClient) deploy(req *shared.DeployRequest) error {
err = untar(fname)
}
if err == nil {
if err == nil && len(req.Config) > 0 {
// config.json도 다운로드
_, err = download(root, hc.makeDownloadUrl(req.Config), req.AccessToken)
}
@ -294,7 +311,8 @@ func (hc *houstonClient) deploy(req *shared.DeployRequest) error {
}
func (hc *houstonClient) withdraw(req *shared.WithdrawRequest) error {
fd, _ := os.Stat(path.Join(req.Name, req.Version))
targetPath := path.Join(hc.config.StorageRoot, req.Name, req.Version)
fd, _ := os.Stat(targetPath)
if fd != nil {
if fd.IsDir() {
for _, running := range hc.childProcs {
@ -304,7 +322,7 @@ func (hc *houstonClient) withdraw(req *shared.WithdrawRequest) error {
}
}
return os.RemoveAll(path.Join(req.Name, req.Version))
return os.RemoveAll(targetPath)
}
}

View File

@ -12,14 +12,12 @@ import (
"os/exec"
"path"
"path/filepath"
"regexp"
"runtime/debug"
"strings"
"syscall"
"time"
"repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/houston/shared"
"repositories.action2quare.com/ayo/houston/shared/protos"
)
@ -54,9 +52,9 @@ func (hc *houstonClient) uploadZipLogFile(zipFile string, name string, version s
defer zf.Close()
req, err := http.NewRequest("POST", hc.httpAddr+"/upload", zf)
req, err := http.NewRequest("POST", hc.config.HttpAddress+"/upload", zf)
if err != nil {
logger.Error(err)
logger.Println(err)
}
req.Header.Set("Houston-Service-Name", name)
req.Header.Set("Houston-Service-Version", version)
@ -75,8 +73,8 @@ func (hc *houstonClient) uploadZipLogFile(zipFile string, name string, version s
return nil
}
func zipLogFiles(req *shared.UploadRequest, start, except string) (string, []string, error) {
root := path.Join(req.Name, req.Version)
func zipLogFiles(storageRoot string, req *shared.UploadRequest, start, except string) (string, []string, error) {
root := path.Join(storageRoot, req.Name, req.Version)
matches, err := filepath.Glob(path.Join(root, req.Filter))
if err != nil {
return "", nil, err
@ -104,11 +102,12 @@ func zipLogFiles(req *shared.UploadRequest, start, except string) (string, []str
defer w.Close()
oldestFile := ""
for _, file := range matches {
for i, file := range matches {
if file == root {
continue
}
if len(except) > 0 && file >= except {
matches = matches[:i]
break
}
if len(start) > 0 && file < start {
@ -121,19 +120,19 @@ func zipLogFiles(req *shared.UploadRequest, start, except string) (string, []str
relative := file[len(root)+1:]
fw, err := w.Create(relative)
if err != nil {
logger.Error(err)
logger.Println(err)
return "", nil, err
}
src, err := os.Open(file)
if err != nil {
logger.Error(err)
logger.Println(err)
return "", nil, err
}
defer src.Close()
if _, err = io.Copy(fw, src); err != nil {
logger.Error(err)
logger.Println(err)
return "", nil, err
}
}
@ -165,21 +164,18 @@ func zipLogFiles(req *shared.UploadRequest, start, except string) (string, []str
//return nil
}
func prepareProcessLaunch(req *shared.StartProcessRequest) *procmeta {
re := regexp.MustCompile(`[^\s"']+|"([^"]*)"|'([^']*)`)
args := re.FindAllString(req.Args, -1)
if len(args) == 0 {
func prepareProcessLaunch(storageRoot string, req *shared.StartProcessRequest) *procmeta {
if len(req.Args) == 0 {
return nil
}
verpath := path.Join(req.Name, req.Version)
verpath := path.Join(storageRoot, req.Name, req.Version)
fi, err := os.Stat(verpath)
if err == nil && fi.IsDir() {
args[0] = "./" + path.Clean(strings.TrimPrefix(args[0], "/"))
os.Chmod(path.Join(verpath, args[0]), 0777)
req.Args[0] = "./" + path.Clean(strings.TrimPrefix(req.Args[0], "/"))
os.Chmod(path.Join(verpath, req.Args[0]), 0777)
cmd := exec.Command(args[0], args[1:]...)
cmd := exec.Command(req.Args[0], req.Args[1:]...)
cmd.Dir = verpath
stdin, _ := cmd.StdinPipe()
@ -259,7 +255,7 @@ func (hc *houstonClient) launch(meta *procmeta) error {
startFile := uploadStartFile
uploadStartFile = nextFile
go func(startFile, nextFile string) {
zipFile, srcFiles, err := zipLogFiles(req, startFile, nextFile)
zipFile, srcFiles, err := zipLogFiles(hc.config.StorageRoot, req, startFile, nextFile)
if err == nil && len(zipFile) > 0 && len(srcFiles) > 0 {
if err = hc.uploadZipLogFile(zipFile, meta.name, meta.version); err == nil {
for _, oldf := range srcFiles {
@ -278,9 +274,10 @@ func (hc *houstonClient) launch(meta *procmeta) error {
return
}
logfile.Write(bt.buf[:bt.size])
logfile.Sync()
meta.buffers.push(bt.buf)
thisFileSize += bt.size
if thisFileSize > 1024*1024 {
if thisFileSize > 10*1024*1024 {
switchToNextFile()
}
}
@ -324,11 +321,11 @@ func (hc *houstonClient) launch(meta *procmeta) error {
var errPrepareprocessLaunchFailed = errors.New("prepareProcessLaunch failed")
func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest) error {
func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest, op protos.OperationClient) error {
logger.Println("startChildProcess :", *req)
if req.Version == "latest" {
// 최신 버전을 찾음
latest, err := shared.FindLastestVersion(req.Name)
latest, err := shared.FindLastestVersion(hc.config.StorageRoot, req.Name)
if err != nil {
return err
}
@ -336,7 +333,7 @@ func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest) erro
req.Version = latest
}
meta := prepareProcessLaunch(req)
meta := prepareProcessLaunch(hc.config.StorageRoot, req)
if meta == nil {
return errPrepareprocessLaunchFailed
}
@ -352,20 +349,18 @@ func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest) erro
}
}
if argfile, err := os.Create(path.Join(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.Encode(meta.cmd.Args)
argfile.Close()
}
if argfile, err := os.Create(path.Join(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.Encode(meta.cmd.Args)
argfile.Close()
}
hc.childProcs = append(hc.childProcs, meta)
op := protos.NewOperationClient(hc.client)
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
return nil
@ -373,10 +368,10 @@ func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest) erro
var errNoRunningProcess = errors.New("no running processed")
func (hc *houstonClient) stopChildProcess(req *shared.StopProcessRequest) error {
func (hc *houstonClient) stopChildProcess(req *shared.StopProcessRequest, op protos.OperationClient) error {
if req.Version == "latest" {
// 최신 버전을 찾음
latest, err := shared.FindLastestVersion(req.Name)
latest, err := shared.FindLastestVersion(hc.config.StorageRoot, req.Name)
if err != nil {
return err
}
@ -417,17 +412,17 @@ func (hc *houstonClient) stopChildProcess(req *shared.StopProcessRequest) error
if len(killing) > 0 {
for _, proc := range killing {
proc.state = protos.ProcessState_Stopping
if err := proc.cmd.Process.Signal(syscall.SIGTERM); err != nil {
proc.cmd.Process.Signal(os.Kill)
proc.state = protos.ProcessState_Stopping
}
}
op := protos.NewOperationClient(hc.client)
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
for _, proc := range killing {
proc.cmd.Wait()
proc.cmd.Process.Release()
}
hc.childProcs = remains
@ -440,62 +435,32 @@ func (hc *houstonClient) stopChildProcess(req *shared.StopProcessRequest) error
return errNoRunningProcess
}
func (hc *houstonClient) restartChildProcess(req *shared.RestartProcessRequest) error {
if req.Version == "latest" {
// 최신 버전을 찾음
latest, err := shared.FindLastestVersion(req.Name)
if err != nil {
return err
}
req.Version = latest
}
var restarts []*procmeta
func (hc *houstonClient) restartChildProcess(req *shared.RestartProcessRequest, op protos.OperationClient) error {
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.Dir
if _, err := download(root, hc.makeDownloadUrl(req.Config), ""); err != nil {
return err
}
}
proc.state = protos.ProcessState_Restart
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
hc.exitChan <- proc.cmd
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 := protos.NewOperationClient(hc.client)
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
for _, proc := range restarts {
proc.cmd.Wait()
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
}
func (hc *houstonClient) uploadFiles(req *shared.UploadRequest) error {
if req.Version == "latest" {
// 최신 버전을 찾음
latest, err := shared.FindLastestVersion(req.Name)
latest, err := shared.FindLastestVersion(hc.config.StorageRoot, req.Name)
if err != nil {
return err
}
@ -514,13 +479,9 @@ func (hc *houstonClient) uploadFiles(req *shared.UploadRequest) error {
// 실행 중이 아닌 폴더에서도 대상을 찾는다
// 전체 파일을 대상으로
zipFile, srcFiles, err := zipLogFiles(req, "", "")
zipFile, srcFiles, err := zipLogFiles(hc.config.StorageRoot, req, "", "")
if err == nil && len(zipFile) > 0 && len(srcFiles) > 0 {
if err = hc.uploadZipLogFile(zipFile, req.Name, req.Version); err == nil {
for _, oldf := range srcFiles {
os.Remove(oldf)
}
} else {
if err = hc.uploadZipLogFile(zipFile, req.Name, req.Version); err != nil {
logger.Println("uploadZipLogFile failed :", err)
}
} else if err != nil {

14
go.mod
View File

@ -1,17 +1,17 @@
module repositories.action2quare.com/ayo/houston
go 1.19
go 1.18
require (
golang.org/x/text v0.9.0
google.golang.org/grpc v1.55.0
golang.org/x/text v0.10.0
google.golang.org/grpc v1.56.0
google.golang.org/protobuf v1.30.0
repositories.action2quare.com/ayo/gocommon v0.0.0-20230528100715-93bd4f6c0bab
repositories.action2quare.com/ayo/gocommon v0.0.0-20230621052811-06ef97f11d22
)
require (
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/sys v0.9.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
)

24
go.sum
View File

@ -3,20 +3,20 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag=
google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
google.golang.org/grpc v1.56.0 h1:+y7Bs8rtMd07LeXmL3NxcTLn7mUkbKZqEpPhMNkwJEE=
google.golang.org/grpc v1.56.0/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230528100715-93bd4f6c0bab h1:EMlxwDayv3rn8ttJcJuDLYoHA5odVn85+LjdAuw+2dw=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230528100715-93bd4f6c0bab/go.mod h1:ng62uGMGXyQSeuxePG5gJAMtip4Rnspu5Tu7hgvaXns=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230621052811-06ef97f11d22 h1:DImSGNxZrc+Q4WlS1OKMsLAScEfDYLX4XMJdjAaVnXc=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230621052811-06ef97f11d22/go.mod h1:ng62uGMGXyQSeuxePG5gJAMtip4Rnspu5Tu7hgvaXns=

4
houston.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/sh
nohup /home/opdev/houston -client -logfile > /dev/null &

View File

@ -1,24 +1,16 @@
package main
import (
"fmt"
"path"
"testing"
"time"
"repositories.action2quare.com/ayo/houston/client"
)
func TestOperationServer(t *testing.T) {
hc, err := client.NewClient()
if err != nil {
t.Error(err)
return
}
for i := 0; ; i++ {
hc.SetReportMetrics(map[string]float32{
"count": float32(i),
})
time.Sleep(1300 * time.Millisecond)
}
fmt.Println(path.Join("a", "b", "/"))
fmt.Println(path.Join("a", "b/"))
fmt.Println(path.Join("a", "b/", "/"))
fmt.Println(path.Join("a", "b/", "/", "/"))
// token, _ := getMicrosoftAuthoizationToken("30330e18-f407-4e35-a6d6-b734b9fe9ee9", "VTr8Q~VBAUAOSmFiHM~bjgszYXBm9nuGBQCk8cLq")
//go func() {

14
main.go
View File

@ -1,28 +1,24 @@
package main
import (
"flag"
"repositories.action2quare.com/ayo/gocommon/flagx"
"repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/houston/client"
"repositories.action2quare.com/ayo/houston/server"
)
var runAsClient = flag.Bool("client", false, "")
var runAsServer = flag.Bool("server", false, "")
var runAsClient = flagx.Bool("client", false, "")
var runAsServer = flagx.Bool("server", false, "")
func main() {
if !flag.Parsed() {
flag.Parse()
}
flagx.Parse()
if !*runAsClient && !*runAsServer {
logger.Fatal("client or server flag is needed")
return
}
if *runAsClient {
hc, err := client.NewClient()
hc, err := client.NewClient(true)
if err != nil {
logger.Fatal(err)
return

24
make_houston_package.ps1 Normal file
View File

@ -0,0 +1,24 @@
# $ErrorActionPreference = 'SilentlyContinue'
del houston.zip
$Env:GOOS="linux"
$Env:GOARCH="amd64"
go build -ldflags="-s -w" .
cp houston .\replacer\houston
cp config.json .\replacer\config.json
cd replacer
go build -ldflags="-s -w" .
Compress-Archive -Path replacer -DestinationPath houston.zip -Force
Compress-Archive -Path config.json -Update -DestinationPath houston.zip
Compress-Archive -Path houston -Update -DestinationPath houston.zip
del houston
del config.json
del replacer
mv houston.zip ..\houston.zip
cd ..

View File

@ -27,7 +27,8 @@ enum ProcessState {
Stopped = 0;
Stopping = 1;
Running = 2;
Error = 3;
Restart = 3;
Error = 4;
}
message ProcessDescription {
@ -36,8 +37,6 @@ message ProcessDescription {
string version = 3;
ProcessState state = 4;
int32 pid = 5;
int32 stdout_size = 6;
int32 stderr_size = 7;
}
message OperationQueryResponse {

View File

@ -1,20 +1,31 @@
package main
import (
"encoding/json"
"errors"
"fmt"
"io"
"log"
"os"
"os/exec"
"path"
"strconv"
"time"
)
func copy(src, dst string) error {
func copy(src, dst string, stdlog *log.Logger) error {
fi, err := os.Stat(src)
if err != nil {
return err
}
if fi.IsDir() {
entries, _ := os.ReadDir(src)
for _, ent := range entries {
if err := copy(path.Join(src, ent.Name()), path.Join(dst, ent.Name()), stdlog); err != nil {
return err
}
}
return nil
}
inmode := fi.Mode()
in, err := os.Open(src)
@ -44,46 +55,59 @@ func copy(src, dst string) error {
return err
}
stdlog.Println("file copied :", src, dst)
return nil
}
func main() {
logfile, _ := os.OpenFile("replacer.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
defer logfile.Close()
stdlog := log.New(logfile, "", log.LstdFlags)
args := os.Args
// args[1] : 나를 시작한 pid. pid가 종료될 때 까지 기다림
// args[2] : target 폴더
// args[3:] : 다시 시작할 때 넘겨줄 arguments(프로세스 이름 포함)
fmt.Println(args)
stdlog.Println(args)
pid, err := strconv.Atoi(args[1])
if err != nil {
panic(err)
}
proc, err := os.FindProcess(pid)
if err != nil {
panic(err)
}
proc.Wait()
selfext, _ := os.Executable()
entries, _ := os.ReadDir(args[2])
for _, ent := range entries {
if ent.Name() == selfext {
continue
for {
stdlog.Println("wait for terminating of", args[3])
cmd := exec.Command("ps", "-p", args[1])
if err := cmd.Run(); err != nil {
break
}
time.Sleep(time.Second)
}
if ent.IsDir() {
if err := os.MkdirAll(ent.Name(), 0775); err != nil {
panic(err)
}
} else {
if err := copy(path.Join(args[2], ent.Name()), ent.Name()); err != nil {
panic(err)
}
stdlog.Println("target is terminated")
// replacer 제거. 내가 돌고 있으므로 복사는 안된다.
// 내가 실행되기 전에 이미 복사가 되서 나는 최신 버전임
os.Remove(path.Join(args[2], os.Args[0]))
if err := copy(args[2], "", stdlog); err != nil {
stdlog.Fatal(err)
}
nextArgs := args[4:]
if bt, _ := os.ReadFile("@args"); len(bt) > 0 {
var tempArgs []string
if json.Unmarshal(bt, &tempArgs) == nil {
nextArgs = tempArgs
}
}
os.Remove("@args")
os.RemoveAll(args[2])
cmd := exec.Command(args[3], args[4:]...)
err := os.RemoveAll(args[2])
if err != nil {
stdlog.Println("os.RemoveAll failed :", args[2], err)
}
err = os.Chmod(args[3], 0775)
if err != nil {
stdlog.Println("os.Chmod failed :", err)
}
stdlog.Println("exec.Command :", args)
cmd := exec.Command(args[3], nextArgs...)
cmd.Start()
}

View File

@ -2,11 +2,16 @@ package server
import (
"encoding/json"
"errors"
"fmt"
"io"
"io/fs"
"net/http"
"os"
"path"
"regexp"
"strconv"
"strings"
"time"
"repositories.action2quare.com/ayo/gocommon/logger"
@ -18,27 +23,61 @@ import (
현재 접속 중인 Agent 목록을 보여줍니다.
- http method : GET
*/
const (
sub_folder_name_deploys = string("_deploys")
sub_folder_name_downloads = string("_downloads")
)
func (h *houstonHandler) GetAgents(w http.ResponseWriter, r *http.Request) {
enc := json.NewEncoder(w)
enc.Encode(h.Operation().Hosts())
allHosts := h.Operation().Hosts()
enc.Encode(allHosts)
}
func readTagsFromFile(paths ...string) string {
raw, _ := os.ReadFile(path.Join(paths...))
if len(raw) > 0 {
tag := string(raw)
return strings.Trim(tag, "\n")
}
return ""
}
func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request) {
files, err := os.ReadDir(h.deployPath)
if err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
getVersions := func(name string) []string {
var out []string
files, _ := os.ReadDir(path.Join(h.deployPath, name))
for _, fd := range files {
vers, _ := os.ReadDir(path.Join(h.deployPath, name))
mytags := readTagsFromFile(h.deployPath, name, "@tags")
out := []string{
mytags,
}
for _, fd := range vers {
if fd.IsDir() {
out = append(out, fd.Name())
ver := fd.Name()
files, _ := os.ReadDir(path.Join(h.deployPath, name, ver))
vertags := readTagsFromFile(h.deployPath, name, ver, "@tags")
if len(files) > 0 {
for _, file := range files {
if strings.HasPrefix(file.Name(), "@") {
continue
}
downloadpath := path.Join(sub_folder_name_deploys, name, ver, file.Name())
ver = fmt.Sprintf("%s:%s", ver+mytags+vertags, downloadpath)
break
}
}
out = append(out, ver)
}
}
return out
}
@ -62,7 +101,7 @@ func (h *houstonHandler) UploadDeploySource(w http.ResponseWriter, r *http.Reque
// </form>
file, header, err := r.FormFile("file")
if err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
@ -70,7 +109,7 @@ func (h *houstonHandler) UploadDeploySource(w http.ResponseWriter, r *http.Reque
contents, err := io.ReadAll(file)
if err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
@ -82,14 +121,18 @@ func (h *houstonHandler) UploadDeploySource(w http.ResponseWriter, r *http.Reque
var filename string
if version == "config" {
filename = path.Join(h.deployPath, name, version, "config.json")
filename = path.Join(h.deployPath, name, version, "config"+ext)
tags := readTagsFromFile(h.deployPath, name, version, "@tags")
if !strings.Contains(tags, "#hidden") {
tags = tags + "#hidden"
os.WriteFile(path.Join(h.deployPath, name, version, "@tags"), []byte(tags), 0644)
}
} else {
// deploys 폴더는 파일시스템 서비스이므로 다운로드 가능
filename = path.Join(h.deployPath, name, version, name+ext)
}
if err = os.MkdirAll(path.Dir(filename), 0775); err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
@ -97,7 +140,7 @@ func (h *houstonHandler) UploadDeploySource(w http.ResponseWriter, r *http.Reque
// 파일 저장
err = os.WriteFile(filename, contents, 0644)
if err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
@ -125,6 +168,47 @@ func (h *houstonHandler) DeleteDeploySource(w http.ResponseWriter, r *http.Reque
}
}
func (h *houstonHandler) findLastestConfigFile(name string) (string, error) {
logger.Println("findLastestConfigFile :", name)
configFiles, err := os.ReadDir(path.Join(h.deployPath, name, "config"))
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
return "", nil
}
logger.Println("findLastestConfigFile failed :", err)
return "", err
}
var cf fs.FileInfo
for _, file := range configFiles {
if file.IsDir() {
continue
}
if strings.HasPrefix(file.Name(), "config.") {
test, err := file.Info()
if err != nil {
return "", err
}
if cf == nil {
cf = test
} else if test.ModTime().After(cf.ModTime()) {
cf = test
}
}
}
if cf != nil {
logger.Println("findLastestConfigFile cf found :", cf.Name())
return path.Join(sub_folder_name_deploys, name, "config", cf.Name()), nil
}
logger.Println("findLastestConfigFile cf NOT found")
return "", nil
}
func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) {
// <form action="/houston" method="post" enctype="multipart/form-data">
// <input type="text" name="name">
@ -139,7 +223,7 @@ func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) {
var targets []string
if len(traws) > 0 {
if err := json.Unmarshal([]byte(traws), &targets); err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
@ -153,7 +237,7 @@ func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) {
relPath := path.Join(h.deployPath, name, version)
files, err := os.ReadDir(relPath)
if err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
@ -165,6 +249,10 @@ func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) {
continue
}
if strings.HasPrefix(fd.Name(), "@") {
continue
}
fi, _ := fd.Info()
if fi.ModTime().After(latestTime) {
latestFilename = fi.Name()
@ -176,12 +264,19 @@ func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) {
return
}
configPath, err := h.findLastestConfigFile(name)
if err != nil {
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
h.Operation().Deploy(MakeDeployRequest(
shared.DeployRequest{
Name: name,
Version: version,
Url: path.Join("deploys", name, version, latestFilename),
Config: path.Join("deploys", name, "config", "config.json"),
Url: path.Join(sub_folder_name_deploys, name, version, latestFilename),
Config: configPath,
},
targets,
))
@ -200,7 +295,7 @@ func (h *houstonHandler) Undeploy(w http.ResponseWriter, r *http.Request) {
var targets []string
if len(traws) > 0 {
if err := json.Unmarshal([]byte(traws), &targets); err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
@ -230,13 +325,13 @@ func (h *houstonHandler) StartProcess(w http.ResponseWriter, r *http.Request) {
// </form>
name := r.FormValue("name")
version := r.FormValue("version")
args := r.FormValue("args")
argsline := r.FormValue("args")
traws := r.FormValue("targets")
var targets []string
if len(traws) > 0 {
if err := json.Unmarshal([]byte(traws), &targets); err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
@ -247,6 +342,27 @@ func (h *houstonHandler) StartProcess(w http.ResponseWriter, r *http.Request) {
return
}
re := regexp.MustCompile(`[^\s"']+|"([^"]*)"|'([^']*)`)
argsTemp := re.FindAllString(argsline, -1)
var args []string
for _, arg := range argsTemp {
if strings.HasPrefix(arg, `"`) && len(args) > 0 {
lastarg := args[len(args)-1]
if strings.HasSuffix(lastarg, "=") {
args[len(args)-1] = lastarg + arg
} else {
args = append(args, arg)
}
} else {
args = append(args, arg)
}
}
if len(args) == 0 {
w.WriteHeader(http.StatusBadRequest)
return
}
h.Operation().StartProcess(MakeStartProcessRequest(shared.StartProcessRequest{
Name: name,
Version: version,
@ -275,7 +391,7 @@ func (h *houstonHandler) StopProcess(w http.ResponseWriter, r *http.Request) {
var targets []string
if len(traws) > 0 {
if err := json.Unmarshal([]byte(traws), &targets); err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
@ -290,6 +406,51 @@ func (h *houstonHandler) StopProcess(w http.ResponseWriter, r *http.Request) {
}, targets))
}
func (h *houstonHandler) RestartProcess(w http.ResponseWriter, r *http.Request) {
// <form action="/houston" method="post" enctype="multipart/form-data">
// <input type="text" name="name">
// <input type="text" name="target">
// <input type="text" name="pid">
// <input type="text" name="config">
// </form>
pidstr := r.FormValue("pid")
target := r.FormValue("target")
name := r.FormValue("name")
if len(target) == 0 || len(pidstr) == 0 || len(name) == 0 {
w.WriteHeader(http.StatusBadRequest)
return
}
deployConfig := false
configstr := r.FormValue("config")
if len(configstr) > 0 {
deployConfig, _ = strconv.ParseBool(configstr)
}
pid, err := strconv.ParseInt(pidstr, 10, 0)
if err != nil {
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
var configPath string
if deployConfig {
configPath, err = h.findLastestConfigFile(name)
if err != nil {
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
}
h.Operation().RestartProcess(MakeRestartRequest(shared.RestartProcessRequest{
Name: name,
Pid: int32(pid),
Config: configPath,
}, []string{target}))
}
func (h *houstonHandler) UploadLogs(w http.ResponseWriter, r *http.Request) {
// <form action="/houston" method="post" enctype="multipart/form-data">
// <input type="text" name="name">
@ -312,7 +473,7 @@ func (h *houstonHandler) UploadLogs(w http.ResponseWriter, r *http.Request) {
}
var targets []string
if err := json.Unmarshal([]byte(traws), &targets); err != nil {
logger.Error(err)
logger.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
@ -338,7 +499,7 @@ func (h *houstonHandler) GetLogFileLinks(w http.ResponseWriter, r *http.Request)
}
if version == "latest" {
version, _ = shared.FindLastestVersion(path.Join(h.downloadPath, name))
version, _ = shared.FindLastestVersion(h.downloadPath, name)
}
root := path.Join(h.downloadPath, name, version)
@ -350,7 +511,7 @@ func (h *houstonHandler) GetLogFileLinks(w http.ResponseWriter, r *http.Request)
var out []string
for _, lf := range logfiles {
out = append(out, path.Join(root, lf.Name()))
out = append(out, path.Join(sub_folder_name_downloads, name, version, lf.Name()))
}
enc := json.NewEncoder(w)

View File

@ -1,6 +1,7 @@
package server
import (
"encoding/json"
"fmt"
"io"
"net/http"
@ -10,13 +11,10 @@ import (
"runtime/debug"
"strings"
"repositories.action2quare.com/ayo/gocommon/flagx"
"repositories.action2quare.com/ayo/gocommon/logger"
)
const (
defaultMaxMemory = 32 << 10 // 32 KB
)
type HoustonServerWithHandler interface {
HoustonServer
RegisterHandlers(serveMux *http.ServeMux, prefix string) error
@ -45,9 +43,10 @@ func NewHoustonHandler() HoustonServerWithHandler {
}
func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string) error {
storagePath := loadServerConfig().StoragePath
h.deployPath = path.Join(storagePath, "deploys")
h.downloadPath = path.Join(storagePath, "downloads")
config := loadServerConfig()
storagePath := config.StorageRoot
h.deployPath = path.Join(storagePath, sub_folder_name_deploys)
h.downloadPath = path.Join(storagePath, sub_folder_name_downloads)
if err := os.MkdirAll(h.deployPath, 0775); err != nil {
return err
@ -65,10 +64,10 @@ func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string
serveMux.Handle(prefix, h)
fsx := http.FileServer(http.Dir(h.deployPath))
serveMux.Handle(fmt.Sprintf("%s/deploys/", prefix), http.StripPrefix(fmt.Sprintf("%s/deploys/", prefix), fsx))
serveMux.Handle(fmt.Sprintf("%s/%s/", prefix, sub_folder_name_deploys), http.StripPrefix(fmt.Sprintf("%s/%s/", prefix, sub_folder_name_deploys), fsx))
ufsx := http.FileServer(http.Dir(h.downloadPath))
serveMux.Handle(fmt.Sprintf("%s/downloads/", prefix), http.StripPrefix(fmt.Sprintf("%s/downloads/", prefix), ufsx))
serveMux.Handle(fmt.Sprintf("%s/%s/", prefix, sub_folder_name_downloads), http.StripPrefix(fmt.Sprintf("%s/%s/", prefix, sub_folder_name_downloads), ufsx))
serveMux.HandleFunc(fmt.Sprintf("%s/upload", prefix), func(w http.ResponseWriter, r *http.Request) {
defer func() {
@ -103,6 +102,8 @@ func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string
return nil
}
var noauth = flagx.Bool("noauth", false, "")
func (h *houstonHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer func() {
s := recover()
@ -117,6 +118,38 @@ func (h *houstonHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r.Body.Close()
}()
var userinfo map[string]any
if !*noauth {
authheader := r.Header.Get("Authorization")
if len(authheader) == 0 {
logger.Println("Authorization header is not valid :", authheader)
w.WriteHeader(http.StatusBadRequest)
return
}
req, _ := http.NewRequest("GET", "https://graph.microsoft.com/oidc/userinfo", nil)
req.Header.Add("Authorization", authheader)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
logger.Println("graph microsoft api call failed :", err)
w.WriteHeader(http.StatusBadRequest)
return
}
defer resp.Body.Close()
raw, _ := io.ReadAll(resp.Body)
if err = json.Unmarshal(raw, &userinfo); err != nil {
return
}
if _, expired := userinfo["error"]; expired {
w.WriteHeader(http.StatusUnauthorized)
return
}
}
var operation string
if r.Method == "POST" {
operation = r.FormValue("operation")
@ -137,15 +170,14 @@ func (h *houstonHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
if r.PostForm == nil {
r.ParseMultipartForm(defaultMaxMemory)
}
args := []reflect.Value{
reflect.ValueOf(h),
reflect.ValueOf(w),
reflect.ValueOf(r),
}
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
method.Func.Call(args)
}

View File

@ -2,13 +2,11 @@ package server
import (
"context"
"encoding/json"
"fmt"
"reflect"
"strings"
"sync"
"repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/houston/shared"
"repositories.action2quare.com/ayo/houston/shared/protos"
)
@ -19,19 +17,17 @@ type opdef struct {
}
type ProcessSnapshot struct {
Name string
Args []string
Version string
State protos.ProcessState
Pid int32
StdoutSize int32
StderrSize int32
Name string `json:"name"`
Args []string `json:"args"`
Version string `json:"version"`
State protos.ProcessState `json:"state"`
Pid int32 `json:"pid"`
}
type hostWithChan struct {
Hostname string
Procs []*protos.ProcessDescription
Deploys map[string][]*protos.VersionAndArgs
Procs []*protos.ProcessDescription `json:"procs"`
Deploys map[string][]*protos.VersionAndArgs `json:"deploys"`
opChan chan *opdef
}
@ -73,9 +69,6 @@ func (sp *hostPool) regist(desc *protos.OperationQueryRequest) (string, chan *op
host = makeHostWithChan(desc).withOpChan(host.opChan)
}
sp.hosts[desc.Hostname] = host
test, _ := json.Marshal(sp.hosts)
logger.Println(string(test))
return desc.Hostname, host.opChan
}
@ -88,9 +81,6 @@ func (sp *hostPool) refresh(desc *protos.OperationQueryRequest) {
host = makeHostWithChan(desc).withOpChan(host.opChan)
sp.hosts[desc.Hostname] = host
}
test, _ := json.Marshal(sp.hosts)
logger.Println(string(test))
}
func (sp *hostPool) unregist(key string) {
@ -101,8 +91,8 @@ func (sp *hostPool) unregist(key string) {
}
type hostSnapshot struct {
Procs []ProcessSnapshot
Deploys map[string][]*protos.VersionAndArgs
Procs []ProcessSnapshot `json:"procs"`
Deploys map[string][]*protos.VersionAndArgs `json:"deploys"`
}
func (sp *hostPool) allHosts() map[string]hostSnapshot {
@ -114,13 +104,11 @@ func (sp *hostPool) allHosts() map[string]hostSnapshot {
procs := make([]ProcessSnapshot, 0, len(v.Procs))
for _, p := range v.Procs {
procs = append(procs, ProcessSnapshot{
Name: p.Name,
Args: p.Args,
Version: p.Version,
State: p.State,
Pid: p.Pid,
StdoutSize: p.StdoutSize,
StderrSize: p.StderrSize,
Name: p.Name,
Args: p.Args,
Version: p.Version,
State: p.State,
Pid: p.Pid,
})
}
out[hn] = hostSnapshot{
@ -163,6 +151,12 @@ func marshal(argval reflect.Value, output map[string]string) map[string]string {
marshal(argval.Field(i), output)
} else if argval.Field(i).CanInt() {
output[argval.Type().Field(i).Name] = fmt.Sprintf("%d", argval.Field(i).Int())
} else if argval.Field(i).Kind() == reflect.Array || argval.Field(i).Kind() == reflect.Slice {
var conv []string
for j := 0; j < argval.Field(i).Len(); j++ {
conv = append(conv, argval.Field(i).Index(j).String())
}
output[argval.Type().Field(i).Name] = strings.Join(conv, "\n")
} else {
output[argval.Type().Field(i).Name] = argval.Field(i).String()
}
@ -171,8 +165,6 @@ func marshal(argval reflect.Value, output map[string]string) map[string]string {
}
func (os *operationServer) Query(svr protos.Operation_QueryServer) error {
// 서버는 업데이트가 있는지 확인하고 있으면 stream에 응답을 보낸다.
// 업데이트가 없으면 대기
desc, err := svr.Recv()
if err != nil {
return err
@ -341,26 +333,18 @@ func (os *operationServer) RestartProcess(d RestartProcessRequest) {
return false
})
if len(d.hostnames) > 0 {
// hostname만 재시작
var final []*hostWithChan
conv := make(map[string]bool)
for _, hn := range d.hostnames {
conv[hn] = true
}
for _, t := range targets {
if _, ok := conv[t.Hostname]; ok {
final = append(final, t)
}
}
targets = final
if len(d.hostnames) != 1 {
return
}
// hostname만 재시작
for _, t := range targets {
t.opChan <- &opdef{
operation: shared.Restart,
args: d,
if t.Hostname == d.hostnames[0] {
t.opChan <- &opdef{
operation: shared.Restart,
args: d,
}
return
}
}
}

View File

@ -5,8 +5,10 @@ import (
"fmt"
"net"
"os"
"sync/atomic"
"repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/houston/client"
"repositories.action2quare.com/ayo/houston/shared"
"repositories.action2quare.com/ayo/houston/shared/protos"
@ -22,7 +24,8 @@ type HoustonServer interface {
type serverConfig struct {
GrpcPort int `json:"grpc_port"`
StoragePath string `json:"storage_path"`
StorageRoot string `json:"storage_path"`
RunAsClient bool `json:"run_as_client"`
}
type DeployRequest struct {
@ -110,7 +113,7 @@ type Operation interface {
func loadServerConfig() serverConfig {
configFile, err := os.Open("config.json")
if err != nil {
logger.Error(err)
logger.Println(err)
return serverConfig{
GrpcPort: 8080,
}
@ -126,14 +129,14 @@ func loadServerConfig() serverConfig {
dec := json.NewDecoder(configFile)
err = dec.Decode(&config)
if err != nil {
logger.Error(err)
logger.Println(err)
return serverConfig{
GrpcPort: 8080,
}
}
if config.Houston == nil {
logger.Error(`"houston" object is missing in config.json`)
logger.Println(`"houston" object is missing in config.json`)
return serverConfig{
GrpcPort: 8080,
}
@ -173,15 +176,34 @@ func (hs *houstonServer) Start() error {
return err
}
if err := hs.rpcServer.Serve(lis); err != nil {
return err
closeCount := int32(0)
var hc client.HoustonClient
if loadServerConfig().RunAsClient {
hc, err = client.NewClient(false)
if err != nil {
return err
}
go func() {
hc.Start()
if atomic.AddInt32(&closeCount, 1) == 1 {
hs.Stop()
}
}()
}
return nil
err = hs.rpcServer.Serve(lis)
if atomic.AddInt32(&closeCount, 1) == 1 {
if hc != nil {
hc.Shutdown()
}
}
return err
}
func (hs *houstonServer) Stop() {
hs.rpcServer.GracefulStop()
hs.rpcServer.Stop()
}
func (hs *houstonServer) Operation() Operation {

View File

@ -3,6 +3,7 @@ package shared
import (
"io/fs"
"os"
"path"
"strings"
)
@ -34,7 +35,7 @@ type WithdrawRequest struct {
type StartProcessRequest struct {
Name string
Version string
Args string
Args []string
}
type StopProcessRequest struct {
@ -44,8 +45,9 @@ type StopProcessRequest struct {
}
type RestartProcessRequest struct {
Name string
Version string
Name string
Pid int32
Config string
}
type UploadRequest struct {
@ -89,9 +91,10 @@ func CompareVersionString(lhs, rhs ParsedVersionString) int {
return len(lhs) - len(rhs)
}
func FindLastestVersion(root string) (string, error) {
func FindLastestVersion(storageRoot, name string) (string, error) {
// 최신 버전을 찾음
entries, err := os.ReadDir(root)
targetPath := path.Join(storageRoot, name)
entries, err := os.ReadDir(targetPath)
if err != nil {
return "", err
}

View File

@ -26,7 +26,8 @@ const (
ProcessState_Stopped ProcessState = 0
ProcessState_Stopping ProcessState = 1
ProcessState_Running ProcessState = 2
ProcessState_Error ProcessState = 3
ProcessState_Restart ProcessState = 3
ProcessState_Error ProcessState = 4
)
// Enum value maps for ProcessState.
@ -35,13 +36,15 @@ var (
0: "Stopped",
1: "Stopping",
2: "Running",
3: "Error",
3: "Restart",
4: "Error",
}
ProcessState_value = map[string]int32{
"Stopped": 0,
"Stopping": 1,
"Running": 2,
"Error": 3,
"Restart": 3,
"Error": 4,
}
)
@ -250,13 +253,11 @@ type ProcessDescription struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Args []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"`
Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
State ProcessState `protobuf:"varint,4,opt,name=state,proto3,enum=ProcessState" json:"state,omitempty"`
Pid int32 `protobuf:"varint,5,opt,name=pid,proto3" json:"pid,omitempty"`
StdoutSize int32 `protobuf:"varint,6,opt,name=stdout_size,json=stdoutSize,proto3" json:"stdout_size,omitempty"`
StderrSize int32 `protobuf:"varint,7,opt,name=stderr_size,json=stderrSize,proto3" json:"stderr_size,omitempty"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Args []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"`
Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
State ProcessState `protobuf:"varint,4,opt,name=state,proto3,enum=ProcessState" json:"state,omitempty"`
Pid int32 `protobuf:"varint,5,opt,name=pid,proto3" json:"pid,omitempty"`
}
func (x *ProcessDescription) Reset() {
@ -326,20 +327,6 @@ func (x *ProcessDescription) GetPid() int32 {
return 0
}
func (x *ProcessDescription) GetStdoutSize() int32 {
if x != nil {
return x.StdoutSize
}
return 0
}
func (x *ProcessDescription) GetStderrSize() int32 {
if x != nil {
return x.StderrSize
}
return 0
}
type OperationQueryResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -419,7 +406,7 @@ var file_protos_operation_proto_rawDesc = []byte{
0x63, 0x73, 0x12, 0x2b, 0x0a, 0x07, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x73, 0x18, 0x03, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x56, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x07, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x73, 0x22,
0xcf, 0x01, 0x0a, 0x12, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x44, 0x65, 0x73, 0x63, 0x72,
0x8d, 0x01, 0x0a, 0x12, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x44, 0x65, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72,
0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x61, 0x72, 0x67, 0x73, 0x12, 0x18,
@ -427,35 +414,32 @@ var file_protos_operation_proto_rawDesc = []byte{
0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74,
0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73,
0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a,
0x03, 0x70, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x70, 0x69, 0x64, 0x12,
0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x06,
0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x53, 0x69, 0x7a, 0x65,
0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x64, 0x65, 0x72, 0x72, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18,
0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x64, 0x65, 0x72, 0x72, 0x53, 0x69, 0x7a,
0x65, 0x22, 0xa6, 0x01, 0x0a, 0x16, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51,
0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09,
0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x35, 0x0a, 0x04, 0x61, 0x72,
0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x2e, 0x41, 0x72, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x61, 0x72, 0x67,
0x73, 0x1a, 0x37, 0x0a, 0x09, 0x41, 0x72, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79,
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x41, 0x0a, 0x0c, 0x50, 0x72,
0x6f, 0x63, 0x65, 0x73, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x74,
0x6f, 0x70, 0x70, 0x65, 0x64, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x74, 0x6f, 0x70, 0x70,
0x69, 0x6e, 0x67, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67,
0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x03, 0x32, 0x78, 0x0a,
0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x05, 0x51, 0x75,
0x65, 0x72, 0x79, 0x12, 0x16, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51,
0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x4f, 0x70,
0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x2b, 0x0a, 0x07, 0x52, 0x65,
0x66, 0x72, 0x65, 0x73, 0x68, 0x12, 0x16, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x06, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x03, 0x70, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22,
0xa6, 0x01, 0x0a, 0x16, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, 0x65,
0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70,
0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f,
0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x35, 0x0a, 0x04, 0x61, 0x72, 0x67, 0x73,
0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e,
0x41, 0x72, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x61, 0x72, 0x67, 0x73, 0x1a,
0x37, 0x0a, 0x09, 0x41, 0x72, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x4e, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x63,
0x65, 0x73, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x74, 0x6f, 0x70,
0x70, 0x65, 0x64, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x74, 0x6f, 0x70, 0x70, 0x69, 0x6e,
0x67, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x10, 0x02,
0x12, 0x0b, 0x0a, 0x07, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x10, 0x03, 0x12, 0x09, 0x0a,
0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x04, 0x32, 0x78, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x16,
0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x2b, 0x0a, 0x07, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68,
0x12, 0x16, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x51, 0x75, 0x65, 0x72,
0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x06, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (