houstonClient도 버전 관리
This commit is contained in:
@ -117,6 +117,8 @@ type houstonClient struct {
|
||||
timestamp string
|
||||
wg sync.WaitGroup
|
||||
config clientConfig
|
||||
version string
|
||||
standalone bool
|
||||
}
|
||||
|
||||
func unmarshal[T any](val *T, src map[string]string) {
|
||||
@ -162,8 +164,25 @@ func gatherDeployedPrograms(storageRoot, name string) []*protos.VersionAndArgs {
|
||||
}
|
||||
|
||||
func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryRequest {
|
||||
hn, _ := os.Hostname()
|
||||
procs := make([]*protos.ProcessDescription, 0, len(hc.childProcs))
|
||||
procs := make([]*protos.ProcessDescription, 0, len(hc.childProcs)+1)
|
||||
if hc.standalone {
|
||||
procs = append(procs, &protos.ProcessDescription{
|
||||
Name: os.Args[0],
|
||||
Args: os.Args[1:],
|
||||
Version: hc.version,
|
||||
State: protos.ProcessState_Running,
|
||||
Pid: int32(os.Getpid()),
|
||||
})
|
||||
} else {
|
||||
procs = append(procs, &protos.ProcessDescription{
|
||||
Name: "houston",
|
||||
Args: []string{},
|
||||
Version: hc.version,
|
||||
State: protos.ProcessState_Running,
|
||||
Pid: int32(os.Getpid()),
|
||||
})
|
||||
}
|
||||
|
||||
for _, child := range hc.childProcs {
|
||||
procs = append(procs, &protos.ProcessDescription{
|
||||
Name: child.name,
|
||||
@ -181,7 +200,7 @@ func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryReque
|
||||
Versions: prog,
|
||||
})
|
||||
}
|
||||
|
||||
hn, _ := os.Hostname()
|
||||
return &protos.OperationQueryRequest{
|
||||
Hostname: hn,
|
||||
Procs: procs,
|
||||
@ -189,7 +208,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
|
||||
@ -238,12 +257,19 @@ func NewClient() (HoustonClient, error) {
|
||||
}
|
||||
}
|
||||
|
||||
ver, _ := os.ReadFile("@version")
|
||||
if len(ver) == 0 {
|
||||
ver = []byte("0.0.0")
|
||||
}
|
||||
|
||||
hc := &houstonClient{
|
||||
config: clientConfig,
|
||||
clientChan: make(chan *grpc.ClientConn),
|
||||
extraMetrics: unsafe.Pointer(&map[string]float32{}),
|
||||
deploys: deploys,
|
||||
timestamp: exefi.ModTime().String(),
|
||||
version: string(ver),
|
||||
standalone: standalone,
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@ -419,6 +445,8 @@ func (hc *houstonClient) Start() {
|
||||
|
||||
var client *grpc.ClientConn
|
||||
reconnCount := 0
|
||||
time.Sleep(time.Second)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-hc.ctx.Done():
|
||||
|
||||
Reference in New Issue
Block a user