本文整理汇总了Python中supervisor.options.make_namespec函数的典型用法代码示例。如果您正苦于以下问题:Python make_namespec函数的具体用法?Python make_namespec怎么用?Python make_namespec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_namespec函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: act
def act(self, subject, msg):
messages = [msg]
def write(msg):
self.stderr.write('%s\n' % msg)
self.stderr.flush()
messages.append(msg)
try:
specs = self.rpc.supervisor.getAllProcessInfo()
except Exception as e:
write('Exception retrieving process info %s, not acting' % e)
return
waiting = list(self.programs)
write(msg)
if self.any:
write('Restarting all running processes')
for spec in specs:
name = spec['name']
group = spec['group']
self.restart(spec, write)
namespec = make_namespec(group, name)
if name in waiting:
waiting.remove(name)
if namespec in waiting:
waiting.remove(namespec)
else:
write('Restarting selected processes %s' % self.programs)
for spec in specs:
name = spec['name']
group = spec['group']
namespec = make_namespec(group, name)
if (name in self.programs) or (namespec in self.programs):
self.restart(spec, write)
if name in waiting:
waiting.remove(name)
if namespec in waiting:
waiting.remove(namespec)
if waiting:
write(
'Programs not restarted because they did not exist: %s' %
waiting)
if self.email:
message = '\n'.join(messages)
self.mail(self.email, subject, message)
开发者ID:wosc,项目名称:superlance,代码行数:49,代码来源:httpok.py
示例2: clearall
def clearall():
if not callbacks:
return results
group, process, callback = callbacks.pop(0)
name = make_namespec(group.config.name, process.config.name)
try:
callback(name)
except RPCError as e:
results.append(
{"name": process.config.name, "group": group.config.name, "status": e.code, "description": e.text}
)
else:
results.append(
{
"name": process.config.name,
"group": group.config.name,
"status": Faults.SUCCESS,
"description": "OK",
}
)
if callbacks:
return NOT_DONE_YET
return results
开发者ID:red-crown,项目名称:supervisor,代码行数:26,代码来源:rpcinterface.py
示例3: do_clear
def do_clear(self, arg):
if not self.ctl.upcheck():
return
names = arg.split()
if not names:
self.ctl.output("Error: clear requires a process name")
self.help_clear()
return
supervisor = self.ctl.get_supervisor()
if "all" in names:
results = supervisor.clearAllProcessLogs()
for result in results:
result = self._clearresult(result)
self.ctl.output(result)
else:
for name in names:
group_name, process_name = split_namespec(name)
try:
result = supervisor.clearProcessLogs(name)
except xmlrpclib.Fault, e:
error = self._clearresult(
{"status": e.faultCode, "name": process_name, "group": group_name, "description": e.faultString}
)
self.ctl.output(error)
else:
name = make_namespec(group_name, process_name)
self.ctl.output("%s: cleared" % name)
开发者ID:JeancarloBarrios,项目名称:adtp,代码行数:31,代码来源:supervisorctl.py
示例4: allfunc
def allfunc(processes=processes,
predicate=predicate,
func=func,
extra_kwargs=extra_kwargs,
callbacks=callbacks, # used only to fool scoping, never passed by caller
results=results): # used only to fool scoping, never passed by caller
if not callbacks:
for group, process in processes:
name = make_namespec(group.config.name, process.config.name)
if predicate(process):
try:
callback = func(name, **extra_kwargs)
except RPCError as e:
results.append({
'name': process.config.name,
'group': group.config.name,
'status': e.code,
'description': e.text
})
continue
if isinstance(callback, types.FunctionType):
callbacks.append((group, process, callback))
else:
results.append({
'name': process.config.name,
'group': group.config.name,
'status': Faults.SUCCESS,
'description': 'OK'
})
if not callbacks:
return results
for struct in callbacks[:]:
group, process, cb = struct
try:
value = cb()
except RPCError as e:
results.append({
'name': process.config.name,
'group': group.config.name,
'status': e.code,
'description': e.text
})
callbacks.remove(struct)
else:
if value is not NOT_DONE_YET:
results.append({
'name': process.config.name,
'group': group.config.name,
'status': Faults.SUCCESS,
'description': 'OK'
})
callbacks.remove(struct)
if callbacks:
return NOT_DONE_YET
return results
开发者ID:alexsilva,项目名称:supervisor,代码行数:60,代码来源:rpcinterface.py
示例5: _restart_process
def _restart_process(self, process_spec):
"""Restart a process.
"""
name_spec = make_namespec(
process_spec[GROUP_KEY], process_spec[NAME_KEY])
rpc_client = childutils.getRPCInterface(self._environment)
process_spec = rpc_client.supervisor.getProcessInfo(name_spec)
if process_spec[STATE_KEY] is ProcessStates.RUNNING:
self._log('Trying to stop process %s', name_spec)
try:
rpc_client.supervisor.stopProcess(name_spec)
self._log('Stopped process %s', name_spec)
except xmlrpclib.Fault as exc:
self._log('Failed to stop process %s: %s', name_spec, exc)
try:
self._log('Starting process %s', name_spec)
rpc_client.supervisor.startProcess(name_spec, False)
except xmlrpclib.Fault as exc:
self._log('Failed to start process %s: %s', name_spec, exc)
else:
self._log('%s not in RUNNING state, cannot restart', name_spec)
开发者ID:klickagent,项目名称:supervisor_checks,代码行数:27,代码来源:check_runner.py
示例6: allfunc
def allfunc(
processes=processes,
predicate=predicate,
func=func,
extra_kwargs=extra_kwargs,
callbacks=callbacks, # used only to fool scoping, never passed by caller
results=results, # used only to fool scoping, never passed by caller
):
if not callbacks:
for group, process in processes:
name = make_namespec(group.config.name, process.config.name)
if predicate(process):
try:
callback = func(name, **extra_kwargs)
except RPCError, e:
results.append({'name':process.config.name,
'group':group.config.name,
'status':e.code,
'description':e.text})
continue
if isinstance(callback, types.FunctionType):
callbacks.append((group, process, callback))
else:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':Faults.SUCCESS,
'description':'OK'}
)
开发者ID:shendadi,项目名称:flaskauth,代码行数:31,代码来源:rpcinterface.py
示例7: restart
def restart(self, spec, write):
namespec = make_namespec(spec['group'], spec['name'])
if spec['state'] is ProcessStates.RUNNING:
if self.coredir and self.gcore:
corename = os.path.join(self.coredir, namespec)
cmd = self.gcore + ' "%s" %s' % (corename, spec['pid'])
with os.popen(cmd) as m:
write('gcore output for %s:\n\n %s' % (
namespec, m.read()))
write('%s is in RUNNING state, restarting' % namespec)
try:
self.rpc.supervisor.stopProcess(namespec)
except xmlrpclib.Fault as e:
write('Failed to stop process %s: %s' % (
namespec, e))
try:
self.rpc.supervisor.startProcess(namespec)
except xmlrpclib.Fault as e:
write('Failed to start process %s: %s' % (
namespec, e))
else:
write('%s restarted' % namespec)
else:
write('%s not in RUNNING state, NOT restarting' % namespec)
开发者ID:Supervisor,项目名称:superlance,代码行数:26,代码来源:httpok.py
示例8: clearall
def clearall():
if not callbacks:
return results
group, process, callback = callbacks.pop(0)
name = make_namespec(group.config.name, process.config.name)
try:
callback(name)
except RPCError as e:
results.append(
{'name': process.config.name,
'group': group.config.name,
'status': e.code,
'description': e.text})
else:
results.append(
{'name': process.config.name,
'group': group.config.name,
'status': Faults.SUCCESS,
'description': 'OK'}
)
if callbacks:
return NOT_DONE_YET
return results
开发者ID:alexsilva,项目名称:supervisor,代码行数:26,代码来源:rpcinterface.py
示例9: stopAllProcesses
def stopAllProcesses(self, wait=True):
""" Stop all processes in the process list
@param boolean wait Wait for each process to be fully stopped
@return array result An array of process status info structs
"""
self._update('stopAllProcesses')
processes = self._getAllProcesses()
results=[]
for group, process in processes:
name = make_namespec(group.config.name, process.config.name)
grp, proc = self._getGroupAndProcess(name)
msg=proc.stop()
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':Faults.SUCCESS,
'description':'OK'}
)
#killall.rpcinterface = self
return results # deferred
开发者ID:kalyanceg,项目名称:supervisor,代码行数:27,代码来源:rpcinterface.py
示例10: stopProcessGroup
def stopProcessGroup(self, name, wait=True):
""" Stop all processes in the process group named 'name'
@param string name The group name
@param boolean wait Wait for each process to be fully stopped
@return array result An array of process status info structs
"""
self._update('stopProcessGroup')
group = self.supervisord.process_groups.get(name)
if group is None:
raise RPCError(Faults.BAD_NAME, name)
processes = group.processes.values()
processes.sort()
processes = [ (group, process) for process in processes ]
results=[]
for group, process in processes:
name = make_namespec(group.config.name, process.config.name)
grp, proc = self._getGroupAndProcess(name)
msg=proc.stop()
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':Faults.SUCCESS,
'description':'OK'}
)
return results # deferred
开发者ID:kalyanceg,项目名称:supervisor,代码行数:32,代码来源:rpcinterface.py
示例11: _restart_processes
def _restart_processes(self):
try:
specs = self.rpc.supervisor.getAllProcessInfo()
except Exception as e:
print("Unable to get process info: {}. No action taken.".format(e), file=self.stderr)
else:
waiting = set(self.restart_programs)
for spec in specs:
name = spec["name"]
namespec = make_namespec(spec["group"], name)
if self.restart_any_program or name in waiting or namespec in waiting:
if spec["state"] is ProcessStates.RUNNING:
print("Restarting process: {}.".format(namespec), file=self.stderr)
try:
self.rpc.supervisor.stopProcess(namespec)
except xmlrpclib.Fault as e:
print("Unable to stop process {}: {}.".format(namespec, e), file=self.stderr)
try:
self.rpc.supervisor.startProcess(namespec)
except xmlrpclib.Fault as e:
print("Unable to start process {}: {}.".format(namespec, e), file=self.stderr)
else:
print("Restarted process {}.".format(namespec), file=self.stderr)
else:
print("Process {} is not in RUNNING state. No action taken.".format(namespec))
waiting.discard(name)
waiting.discard(namespec)
if len(waiting) > 0:
print("Programs specified could not be found: {}.".format(", ".join(waiting)), file=self.stderr)
开发者ID:liambuchanan,项目名称:supervisor-event-exec,代码行数:29,代码来源:supervisor_event_exec.py
示例12: do_clear
def do_clear(self, arg):
if not self.ctl.upcheck():
return
names = arg.split()
if not names:
self.ctl.output('Error: clear requires a process name')
self.help_clear()
return
supervisor = self.ctl.get_supervisor()
if 'all' in names:
results = supervisor.clearAllProcessLogs()
for result in results:
result = self._clearresult(result)
self.ctl.output(result)
else:
for name in names:
group_name, process_name = split_namespec(name)
try:
supervisor.clearProcessLogs(name)
except xmlrpclib.Fault as e:
error = self._clearresult({'status': e.faultCode,
'name': process_name,
'group': group_name,
'description': e.faultString})
self.ctl.output(error)
else:
name = make_namespec(group_name, process_name)
self.ctl.output('%s: cleared' % name)
开发者ID:pataquets,项目名称:supervisor,代码行数:32,代码来源:supervisorctl.py
示例13: match
def match(spec):
name = spec['name']
group = spec['group']
namespec = make_namespec(name, group)
for pattern in self.programs:
if fnmatch.fnmatch(name, pattern) or fnmatch.fnmatch(namespec, pattern):
return True
return False
开发者ID:collective,项目名称:mr.rubber,代码行数:8,代码来源:rubber.py
示例14: logname
def logname(self):
"""
The name of this subprocess as used in logging.
"""
if self.group is None:
return self.config.name
else:
return make_namespec(self.group.config.name, self.config.name)
开发者ID:dvarrazzo,项目名称:supervisor,代码行数:8,代码来源:process.py
示例15: _getGroupProcessInfo
def _getGroupProcessInfo(self, group):
""" Get info about the processes of a certian group
@return array result An array of process status results
"""
output = []
for process in group.processes.values():
name = make_namespec(group.config.name, process.config.name)
output.append(self.getProcessInfo(name))
return output
开发者ID:simonjj,项目名称:supervisor,代码行数:10,代码来源:rpcinterface.py
示例16: stop
def stop(self, spec, write):
namespec = make_namespec(spec['group'], spec['name'])
if spec['state'] is ProcessStates.STOPPED:
return
write('%s is in RUNNING state, stopping' % namespec)
try:
self.rpc.supervisor.stopProcess(namespec)
except xmlrpclib.Fault, what:
write('Failed to stop process %s: %s' % (
namespec, what))
开发者ID:collective,项目名称:mr.rubber,代码行数:10,代码来源:rubber.py
示例17: start
def start(self, spec, write):
namespec = make_namespec(spec['group'], spec['name'])
if spec['state'] is ProcessStates.RUNNING:
return
try:
self.rpc.supervisor.startProcess(namespec)
except xmlrpclib.Fault, what:
write('Failed to start process %s: %s' % (
namespec, what))
开发者ID:collective,项目名称:mr.rubber,代码行数:10,代码来源:rubber.py
示例18: _spawn_as_parent
def _spawn_as_parent(self, pid):
# Parent
self.pid = pid
options = self.config.options
options.close_child_pipes(self.pipes)
options.logger.info('spawned: %r with pid %s' % (make_namespec(self.group.config.name, self.config.name), pid))
self.spawnerr = None
self.delay = time.time() + self.config.startsecs
options.pidhistory[pid] = self
return pid
开发者ID:kozdincer,项目名称:supervisor,代码行数:10,代码来源:process.py
示例19: _clearresult
def _clearresult(self, result):
name = make_namespec(result["group"], result["name"])
code = result["status"]
template = "%s: ERROR (%s)"
if code == xmlrpc.Faults.BAD_NAME:
return template % (name, "no such process")
elif code == xmlrpc.Faults.FAILED:
return template % (name, "failed")
elif code == xmlrpc.Faults.SUCCESS:
return "%s: cleared" % name
raise ValueError("Unknown result code %s for %s" % (code, name))
开发者ID:JeancarloBarrios,项目名称:adtp,代码行数:11,代码来源:supervisorctl.py
示例20: start_stop
def start_stop(self, spec, start=True):
namespec = make_namespec(spec['group'], spec['name'])
if spec['state'] is ProcessStates.RUNNING and not start:
self.write_stderr('%s is in RUNNING state, stopping' % namespec)
try:
self.rpc.supervisor.stopProcess(namespec)
except xmlrpclib.Fault, what:
self.write_stderr('Failed to stop process %s: %s' %
(namespec, what))
else:
self.write_stderr('%s stopped' % namespec)
开发者ID:offlinehacker,项目名称:superlance,代码行数:11,代码来源:httpctrl.py
注:本文中的supervisor.options.make_namespec函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论