本文整理汇总了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)
示例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('}')
示例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('}')
示例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))
示例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)