ing
This commit is contained in:
parent
e6889911bb
commit
eecc41f19b
|
@ -141,13 +141,13 @@ func (s *ContainerService) runContainer(containerType occp.ContainerType) (*cont
|
|||
return nil, err
|
||||
}
|
||||
|
||||
go func(containerType occp.ContainerType, cmd *exec.Cmd) {
|
||||
if err := cmd.Wait(); nil != err {
|
||||
logging.Logger().Error(err)
|
||||
}
|
||||
logging.Logger().Infof("Container[%s] has been stopped", containerType.String())
|
||||
s.refreshContainer(containerType)
|
||||
}(containerType, cmd)
|
||||
// go func(containerType occp.ContainerType, cmd *exec.Cmd) {
|
||||
// if err := cmd.Wait(); nil != err {
|
||||
// logging.Logger().Error(err)
|
||||
// }
|
||||
// logging.Logger().Infof("Container[%s] has been stopped", containerType.String())
|
||||
// s.refreshContainer(containerType)
|
||||
// }(containerType, cmd)
|
||||
|
||||
cs := &containerState{
|
||||
containerType: containerType,
|
||||
|
@ -173,6 +173,7 @@ func (s *ContainerService) refreshContainer(containerType occp.ContainerType) {
|
|||
logging.Logger().Error(err)
|
||||
}
|
||||
cs.client = nil
|
||||
delete(s.containerStates, containerType)
|
||||
if _, err := s.getClient(containerType); nil != err {
|
||||
logging.Logger().Error(err)
|
||||
}
|
||||
|
@ -238,20 +239,20 @@ func (s *ContainerService) checkContainer(containerType occp.ContainerType) *con
|
|||
return nil
|
||||
}
|
||||
|
||||
p, err := os.FindProcess(cs.cmd.Process.Pid)
|
||||
if nil != err {
|
||||
s.removeContainerState(containerType)
|
||||
return nil
|
||||
}
|
||||
if nil == p {
|
||||
s.removeContainerState(containerType)
|
||||
return nil
|
||||
}
|
||||
|
||||
//if nil != cs.cmd.ProcessState && cs.cmd.ProcessState.Exited() {
|
||||
// p, err := os.FindProcess(cs.cmd.Process.Pid)
|
||||
// if nil != err {
|
||||
// s.removeContainerState(containerType)
|
||||
// return nil
|
||||
//}
|
||||
// }
|
||||
// if nil == p {
|
||||
// s.removeContainerState(containerType)
|
||||
// return nil
|
||||
// }
|
||||
|
||||
// if nil != cs.cmd.ProcessState && cs.cmd.ProcessState.Exited() {
|
||||
// s.removeContainerState(containerType)
|
||||
// return nil
|
||||
// }
|
||||
|
||||
return cs
|
||||
}
|
||||
|
@ -276,8 +277,10 @@ func (s *ContainerService) removeContainerState(containerType occp.ContainerType
|
|||
return
|
||||
}
|
||||
|
||||
if nil != cs.client {
|
||||
delete(s.connectorMap, cs.client.Connector)
|
||||
cs.client.Stop(context.Background())
|
||||
}
|
||||
s.killContainer(containerType)
|
||||
delete(s.containerStates, containerType)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user