本文整理匯總了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)