This commit is contained in:
crusader 2018-04-27 16:42:59 +09:00
parent e6889911bb
commit eecc41f19b

View File

@ -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,15 +239,15 @@ 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
}
// 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)
@ -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)
}