houston server에 재접속시 autorun이 다시 불리는 문제 수정
This commit is contained in:
@ -317,6 +317,7 @@ func NewClient(standalone bool) (HoustonClient, error) {
|
|||||||
|
|
||||||
case newClient := <-hc.clientChan:
|
case newClient := <-hc.clientChan:
|
||||||
op = protos.NewOperationClient(newClient)
|
op = protos.NewOperationClient(newClient)
|
||||||
|
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
|
||||||
|
|
||||||
case exited := <-exitChan:
|
case exited := <-exitChan:
|
||||||
var newprocs []*procmeta
|
var newprocs []*procmeta
|
||||||
@ -331,11 +332,15 @@ func NewClient(standalone bool) (HoustonClient, error) {
|
|||||||
proc.cmd.Process.Release()
|
proc.cmd.Process.Release()
|
||||||
|
|
||||||
if proc.isState(protos.ProcessState_Restart) {
|
if proc.isState(protos.ProcessState_Restart) {
|
||||||
hc.startChildProcess(&shared.StartProcessRequest{
|
if err := hc.startChildProcess(&shared.StartProcessRequest{
|
||||||
Version: proc.version,
|
Version: proc.version,
|
||||||
Name: proc.name,
|
Name: proc.name,
|
||||||
Args: proc.args,
|
Args: proc.args,
|
||||||
}, op)
|
}); err != nil {
|
||||||
|
logger.ErrorWithCallStack(err)
|
||||||
|
} else {
|
||||||
|
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}(proc)
|
}(proc)
|
||||||
}
|
}
|
||||||
@ -422,8 +427,10 @@ func NewClient(standalone bool) (HoustonClient, error) {
|
|||||||
case shared.Start:
|
case shared.Start:
|
||||||
var sr shared.StartProcessRequest
|
var sr shared.StartProcessRequest
|
||||||
unmarshal(&sr, resp.Args)
|
unmarshal(&sr, resp.Args)
|
||||||
if err := hc.startChildProcess(&sr, op); err != nil {
|
if err := hc.startChildProcess(&sr); err != nil {
|
||||||
logger.Println(err)
|
logger.ErrorWithCallStack(err)
|
||||||
|
} else {
|
||||||
|
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
|
||||||
}
|
}
|
||||||
|
|
||||||
case shared.Stop:
|
case shared.Stop:
|
||||||
@ -517,6 +524,38 @@ func (hc *houstonClient) Start() {
|
|||||||
reconnCount := 0
|
reconnCount := 0
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
|
if autorun != nil && len(*autorun) > 0 {
|
||||||
|
hascount := strings.Split(*autorun, "/")
|
||||||
|
var service string
|
||||||
|
count := 1
|
||||||
|
if len(hascount) > 1 {
|
||||||
|
service = hascount[0]
|
||||||
|
if len(hascount[1]) > 0 {
|
||||||
|
count, _ = strconv.Atoi(hascount[1])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
service = *autorun
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd, ok := hc.config.Autorun[service]; ok {
|
||||||
|
// service 서비스
|
||||||
|
for i := 0; i < count; i++ {
|
||||||
|
sr := shared.StartProcessRequest{
|
||||||
|
Name: service,
|
||||||
|
Version: cmd.Version,
|
||||||
|
Args: append([]string{cmd.Exec}, cmd.Args...),
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := hc.startChildProcess(&sr); err != nil {
|
||||||
|
logger.Println("startChildProcess failed by autorun :", err)
|
||||||
|
logger.ErrorWithCallStack(err)
|
||||||
|
} else {
|
||||||
|
logger.Println("autorun success :", sr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-hc.ctx.Done():
|
case <-hc.ctx.Done():
|
||||||
@ -548,7 +587,6 @@ func (hc *houstonClient) Start() {
|
|||||||
err := hc.checkOperation(client)
|
err := hc.checkOperation(client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Println("grpc.DialContext hc.checkOperation failed :", err)
|
logger.Println("grpc.DialContext hc.checkOperation failed :", err)
|
||||||
|
|
||||||
client = nil
|
client = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -580,37 +618,6 @@ func (hc *houstonClient) checkOperation(client *grpc.ClientConn) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if autorun != nil && len(*autorun) > 0 {
|
|
||||||
hascount := strings.Split(*autorun, "/")
|
|
||||||
var service string
|
|
||||||
count := 1
|
|
||||||
if len(hascount) > 1 {
|
|
||||||
service = hascount[0]
|
|
||||||
if len(hascount[1]) > 0 {
|
|
||||||
count, _ = strconv.Atoi(hascount[1])
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
service = *autorun
|
|
||||||
}
|
|
||||||
|
|
||||||
if cmd, ok := hc.config.Autorun[service]; ok {
|
|
||||||
// service 서비스
|
|
||||||
for i := 0; i < count; i++ {
|
|
||||||
sr := shared.StartProcessRequest{
|
|
||||||
Name: service,
|
|
||||||
Version: cmd.Version,
|
|
||||||
Args: append([]string{cmd.Exec}, cmd.Args...),
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := hc.startChildProcess(&sr, op); err != nil {
|
|
||||||
logger.Println("startChildProcess failed by autorun :", err)
|
|
||||||
} else {
|
|
||||||
logger.Println("autorun success :", sr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
update, err := cl.Recv()
|
update, err := cl.Recv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -435,7 +435,7 @@ func (hc *houstonClient) launch(meta *procmeta) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest, op protos.OperationClient) error {
|
func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest) error {
|
||||||
meta, err := prepareProcessLaunch(hc.config.StorageRoot, req)
|
meta, err := prepareProcessLaunch(hc.config.StorageRoot, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -465,8 +465,6 @@ func (hc *houstonClient) startChildProcess(req *shared.StartProcessRequest, op p
|
|||||||
}
|
}
|
||||||
|
|
||||||
hc.childProcs = append(hc.childProcs, meta)
|
hc.childProcs = append(hc.childProcs, meta)
|
||||||
op.Refresh(context.Background(), hc.makeOperationQueryRequest())
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user