Beispiel #1
0
def signal_handler(signum, frame):
    # we want the handler to run only for the agent process and not
    # for the children (e.g. namenode, etc.)
    if os.getpid() != agentPid:
        os._exit(0)
    logger.info("signal received, exiting.")
    ProcessHelper.stopAgent()
Beispiel #2
0
def signal_handler(signum, frame):
    #we want the handler to run only for the agent process and not
    #for the children (e.g. namenode, etc.)
    if os.getpid() != agentPid:
        os._exit(0)
    logger.info('signal received, exiting.')
    ProcessHelper.stopAgent()
Beispiel #3
0
def signal_handler(signum, frame):
  #we want the handler to run only for the agent process and not
  #for the children (e.g. namenode, etc.)
  if os.getpid() != agentPid:
    os._exit(0)
  logger.info('signal received, exiting.')
  global controller
  if controller is not None and hasattr(controller, 'actionQueue'):
    docker_mode = controller.actionQueue.docker_mode
    if docker_mode:
      tmpdir = controller.actionQueue.dockerManager.stop_container()
  ProcessHelper.stopAgent()
    def __call__(self):
        if len(self) == 0:
            self.__print_proxy('monitor process list is empty!')
            return

        self.__print_proxy(format('start', '*^26s'))
        for (pid, start_time) in self.subprocess.items():
            tips = ['doing', (pid, start_time), ProcessHelper.core_info(pid)]
            self.__print_proxy(':'.join(str(s) for s in tips))
        for (pid, start_time) in self.rest_subprocess.items():
            tips = ['reset', (pid, start_time), ProcessHelper.core_info(pid)]
            self.__print_proxy(':'.join(str(s) for s in tips))
        self.__print_proxy(format('end', '*^26s'))
 def kill_all(self):
     """
     结束所有,对外
     :return:
     """
     all_ps = chain(self.subprocess.keys(), self.rest_subprocess.keys())
     for pid in all_ps:
         ProcessHelper.terminate(pid)
     """
         TODO:
         1 有可能没有kill掉, 没有再次检查
         2 针对kill 添加kill -9增加kill在普通kill失败后
     """
     self.subprocess.clear()
     self.rest_subprocess.clear()
    def _check_living(self, pid, option=None):
        """
        进程活着就返回,否则尝试从config中remove
        :param pid:
        :param option:
        :return:
        """
        if ProcessHelper.is_living(pid):
            return True

        try_cnt = g_try_cnt
        while True:
            self.cf.read(K_CMD_PNAME)
            options = self.cf.options(K_CMD_PCMD)
            if option is None:
                option = K_CMD_PCMD_ADD_HEAD + str(pid)
            if options.count(option) == 0:
                break

            if try_cnt <> g_try_cnt:
                '''
                    除来第一次之外都sleep一下
                '''
                time.sleep(1)

            self.cf.remove_option(K_CMD_PCMD, option)
            with open(K_CMD_PNAME, 'w') as f:
                self.cf.write(f)

            try_cnt -= 1
            if try_cnt == 0:
                self.__print_proxy('check_living failed pid: ' + str(pid))
                break
        return False
Beispiel #7
0
def signal_handler(signum, frame):
  #we want the handler to run only for the agent process and not
  #for the children (e.g. namenode, etc.)
  if os.getpid() != agentPid:
    os._exit(0)
  logger.info('signal received, exiting.')
  global controller
  if controller is not None and hasattr(controller, 'actionQueue') and controller.actionQueue.yarn_docker_mode == False:
    docker_mode = controller.actionQueue.docker_mode
    if docker_mode:
      tmpdir = controller.actionQueue.dockerManager.stop_container()

  if controller is not None and hasattr(controller, 'stopCommand') and controller.stopCommand is not None:
    controller.stopCommand = _increment_task_id(controller.stopCommand)
    controller.appGracefulStopQueued = True
    controller.actionQueue.execute_command(controller.stopCommand)

  ProcessHelper.stopAgent()
 def __resume(self, pid):
     tips = 'pid %d resume :%s' % (pid, str(datetime.datetime.now()))
     self.__print_proxy(tips)
     ProcessHelper.resume(pid)
 def __suspend(self, pid):
     tips = 'pid %d suspend :%s' % (pid, str(datetime.datetime.now()))
     self.__print_proxy(tips)
     ProcessHelper.suspend(pid)