예제 #1
0
 def try_to_kill_process_exist(self):
     """
     Try to kill process, if already exist
     """
     script_path = os.path.realpath(
         os.path.join(self.install_path, Constant.ANORMALY_MAIN_SCRIPT))
     process_list = [
         (cmd % (Constant.CMD_PREFIX, os.path.dirname(script_path),
                 script_path)).split(self.version)[-1]
         for cmd in self.service_list
     ]
     for process in process_list:
         process_num = CommonTools.check_process(process)
         if process_num:
             CommonTools.grep_process_and_kill(process)
             g.logger.info('Killed process of [%s]' % process)
예제 #2
0
 def waiting_for_start(self, wait_seconds):
     """
     Wait cron start agent, server and monitor in 1m.
     """
     script_path = os.path.realpath(
         os.path.join(self.install_path, Constant.ANORMALY_MAIN_SCRIPT))
     process_list = [
         (cmd % (Constant.CMD_PREFIX, os.path.dirname(script_path),
                 script_path)).split(self.version)[-1]
         for cmd in self.service_list
     ]
     ret_mapping = {}
     for sec in range(wait_seconds):
         for process in process_list:
             process_num = CommonTools.check_process(process)
             ret_mapping[process] = process_num
         if all(ret_mapping.values()):
             g.logger.info('Successfully start all process.')
             return
         time.sleep(1)
     g.logger.error('Failed start all process with result:%s' %
                    str(ret_mapping))
     raise Exception(Errors.EXECUTE_RESULT['gauss_0416'])
예제 #3
0
 def check_process_exist():
     count = CommonTools.check_process('ai_manager')
     if count > 1:
         raise Exception(Errors.PERMISSION['gauss_0702'] % 'ai_manager')
     else:
         g.logger.debug('Check process passed.')