当前位置: 首页>>代码示例>>Python>>正文


Python ProcessContext.remove_pid_file方法代码示例

本文整理汇总了Python中system.process_context.ProcessContext.remove_pid_file方法的典型用法代码示例。如果您正苦于以下问题:Python ProcessContext.remove_pid_file方法的具体用法?Python ProcessContext.remove_pid_file怎么用?Python ProcessContext.remove_pid_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在system.process_context.ProcessContext的用法示例。


在下文中一共展示了ProcessContext.remove_pid_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: stop_process

# 需要导入模块: from system.process_context import ProcessContext [as 别名]
# 或者: from system.process_context.ProcessContext import remove_pid_file [as 别名]
def stop_process(options):
    """Stop the synergy-data daemons"""
    import logging
    from supervisor import supervisor_helper as helper
    from model.box_configuration_entry import BoxConfigurationEntry

    if options.app is not None and options.app != process_context.PROCESS_SUPERVISOR:
        # mark individual process for termination
        # real work is performed by Supervisor
        if options.app not in PROCESSES_FOR_XXL:
            sys.stdout.write("ERROR: requested process must be withing allowed list of: %r \n" % PROCESSES_FOR_XXL)
            sys.exit(1)

        box_id = helper.get_box_id(logging)
        box_configuration = helper.retrieve_configuration(logging, box_id)
        box_configuration.set_process_state(options.app, BoxConfigurationEntry.STATE_OFF)
        helper.update_configuration(logging, box_configuration)
    else:
        # stop Supervisor
        try:
            pid = _get_supervisor_pid()
            if pid is None:
                message = "ERROR: Can not find Supervisor pidfile. Supervisor not running?\n"
                sys.stderr.write(message)
                sys.exit(1)

            # Try killing the daemon process
            sys.stdout.write("INFO: Killing %r \n" % process_context.PROCESS_SUPERVISOR)
            while 1:
                os.kill(pid, signal.SIGTERM)
                time.sleep(0.1)
            ProcessContext.remove_pid_file(process_context.PROCESS_SUPERVISOR)
        except Exception as e:
            sys.stderr.write("Exception on killing %s : %s \n" % (process_context.PROCESS_SUPERVISOR, str(e)))
            sys.exit(0)
开发者ID:stutiredboy,项目名称:scheduler,代码行数:37,代码来源:launch.py

示例2: kill_process

# 需要导入模块: from system.process_context import ProcessContext [as 别名]
# 或者: from system.process_context.ProcessContext import remove_pid_file [as 别名]
def kill_process(process_name):
    """ method is called to kill a running process """
    try:
        sys.stdout.write('killing: %s { \n' % process_name)
        pid = get_process_pid(process_name)
        if pid is not None and psutil.pid_exists(int(pid)):
            p = psutil.Process(pid)
            p.kill()
            p.wait()
            ProcessContext.remove_pid_file(process_name)
    except Exception as e:
        sys.stderr.write('Exception on killing %s : %s \n' % (process_name, str(e)))
    finally:
        sys.stdout.write('}')
开发者ID:NMerch,项目名称:scheduler,代码行数:16,代码来源:process_helper.py

示例3: _kill_process

# 需要导入模块: from system.process_context import ProcessContext [as 别名]
# 或者: from system.process_context.ProcessContext import remove_pid_file [as 别名]
 def _kill_process(self, box_config, process_name):
     """ method is called to kill a running process """
     try:
         self.logger.info('kill: %s {' % process_name)
         pid = box_config.get_process_pid(process_name)
         if pid is not None and psutil.pid_exists(int(pid)):
             p = psutil.Process(pid)
             p.kill()
             p.wait()
             box_config.set_process_pid(process_name, None)
             self.bc_dao.update(box_config)
             ProcessContext.remove_pid_file(process_name)
     except Exception:
         self.logger.error('Exception on killing: %s' % process_name, exc_info=True)
     finally:
         self.logger.info('}')
开发者ID:NMerch,项目名称:scheduler,代码行数:18,代码来源:synergy_supervisor.py

示例4: __del__

# 需要导入模块: from system.process_context import ProcessContext [as 别名]
# 或者: from system.process_context.ProcessContext import remove_pid_file [as 别名]
 def __del__(self):
     """ removes PID file """
     ProcessContext.remove_pid_file(self.process_name, process_id=self.process_id)
     self.logger.info('Shutdown {0}'.format(self.process_name))
开发者ID:mushkevych,项目名称:launch.py,代码行数:6,代码来源:synergy_process.py

示例5: __del__

# 需要导入模块: from system.process_context import ProcessContext [as 别名]
# 或者: from system.process_context.ProcessContext import remove_pid_file [as 别名]
 def __del__(self):
     """ removes PID file """
     ProcessContext.remove_pid_file(self.process_name)
     self.logger.info('Shutdown %s' % self.process_name)
开发者ID:strategist922,项目名称:scheduler,代码行数:6,代码来源:synergy_process.py


注:本文中的system.process_context.ProcessContext.remove_pid_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。