本文整理汇总了Python中supervisor.childutils.eventdata函数的典型用法代码示例。如果您正苦于以下问题:Python eventdata函数的具体用法?Python eventdata怎么用?Python eventdata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eventdata函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: runforever
def runforever(self):
while 1:
# we explicitly use self.stdin, self.stdout, and self.stderr
# instead of sys.* so we can unit test this code
headers, payload = childutils.listener.wait(self.stdin, self.stdout)
pheaders, pdata = childutils.eventdata(payload + '\n')
pheaders['eventname'] = headers['eventname'].split('_')[-1]
self.stderr.write(str(self.excluded))
if not headers['eventname'] == 'PROCESS_STATE_EXITED' and not pheaders['from_state'] == 'EXITED' and not \
headers['eventname'] == 'PROCESS_STATE_FATAL':
# do nothing with non-TICK events
childutils.listener.ok(self.stdout)
continue
if pheaders['processname'] in self.excluded:
# do nothing with excluded processes
childutils.listener.ok(self.stdout)
continue
if not self.any and pheaders['processname'] not in self.programs:
# do nothing with processes not asked
childutils.listener.ok(self.stdout)
continue
msg = ('Process %(processname)s, in group %(groupname)s, '
' moved to %(eventname)s from state %(from_state)s' %
pheaders)
subject = ' %s %s at %s' % (pheaders['processname'], pheaders['eventname'],
childutils.get_asctime())
if self.optionalheader:
subject = self.optionalheader + ':' + subject
self.mail(subject, msg)
childutils.listener.ok(self.stdout)
开发者ID:sumitkumar1209,项目名称:superlanceadds,代码行数:33,代码来源:sesmail.py
示例2: Run
def Run(self, test):
while True:
# we explicitly use self.stdin, self.stdout, and self.stderr
# instead of sys.* so we can unit test this code
headers, payload = self._event_listener.wait(
self._stdin, self._stdout)
pheaders, pdata = childutils.eventdata(payload + '\n')
# check for process state change events
if headers['eventname'].startswith("PROCESS_STATE"):
"""
eventname:PROCESS_STATE_STARTING processname:cat groupname:cat from_state:STOPPED tries:0
eventname:PROCESS_STATE_RUNNING processname:cat groupname:cat from_state:STARTING pid:2766
eventname:PROCESS_STATE_BACKOFF processname:cat groupname:cat from_state:STOPPED tries:0
eventname:PROCESS_STATE_STOPPING processname:cat groupname:cat from_state:STARTING pid:2766
eventname:PROCESS_STATE_EXITED processname:cat groupname:cat from_state:RUNNING expected:0 pid:2766
eventname:PROCESS_STATE_STOPPED processname:cat groupname:cat from_state:STOPPING pid:2766
eventname:PROCESS_STATE_FATAL processname:cat groupname:cat from_state:BACKOFF
eventname:PROCESS_STATE_UNKNOWN processname:cat groupname:cat from_state:BACKOFF
"""
process_info = {}
process_info['name'] = pheaders['processname']
process_info['group'] = pheaders['groupname']
process_info['state'] = headers['eventname']
if 'pid' in pheaders:
process_info['pid'] = pheaders['pid']
if 'expected' in pheaders:
process_info['expected'] = int(pheaders['expected'])
self._event_handlers['PROCESS_STATE'](process_info)
if self._update_process_list:
self._event_handlers['PROCESS_LIST_UPDATE']()
# check for flag value change events
if headers['eventname'].startswith("PROCESS_COMMUNICATION"):
self._event_handlers['PRCOESS_COMMUNICATION'](pdata)
self._event_listener.ok(self._stdout)
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:34,代码来源:event_manager.py
示例3: runforever
def runforever(self, test=False):
self.prev_current_time = int(time.time())
while 1:
# we explicitly use self.stdin, self.stdout, and self.stderr
# instead of sys.* so we can unit test this code
headers, payload = \
self.listener_nodemgr.wait(self.stdin, self.stdout)
# self.stderr.write("headers:\n" + str(headers) + '\n')
# self.stderr.write("payload:\n" + str(payload) + '\n')
pheaders, pdata = childutils.eventdata(payload + '\n')
# self.stderr.write("pheaders:\n" + str(pheaders)+'\n')
# self.stderr.write("pdata:\n" + str(pdata))
# check for process state change events
if headers['eventname'].startswith("PROCESS_STATE"):
self.event_process_state(pheaders, headers)
# check for addition / deletion of processes in the node.
# Tor Agent process can get added / deleted based on need.
self.update_current_process()
# check for flag value change events
if headers['eventname'].startswith("PROCESS_COMMUNICATION"):
self.event_process_communication(pdata)
# do periodic events
if headers['eventname'].startswith("TICK_60"):
self.event_tick_60()
# loadbalancer processing
self.lb_stats.send_loadbalancer_stats()
self.listener_nodemgr.ok(self.stdout)
开发者ID:dsundarraj,项目名称:contrail-controller,代码行数:33,代码来源:vrouter_event_manager.py
示例4: run_forever
def run_forever(self):
while True:
# we explicitly use self.stdin, self.stdout, and self.stderr
# instead of sys.* so we can unit test this code
headers, payload = childutils.listener.wait(self.stdin, self.stdout)
if headers['eventname'] in ['PROCESS_STATE_RUNNING', 'PROCESS_STATE_EXITED']:
pheaders, pdata = childutils.eventdata(payload + '\n')
pid = int(pheaders['pid'])
event = Event(id=str(uuid4()), ts=int(time.time()), pid=pid,
groupname=pheaders['groupname'],
processname=pheaders['processname'])
if headers['eventname'] == 'PROCESS_STATE_RUNNING':
event.eventname = 'STARTED'
# start a thread to kill the process if there is a max runtime
if pheaders['processname'] in self.programs:
timer = Timer(self.programs[pheaders['processname']].total_seconds(), os.kill, [pid, signal.SIGTERM])
timer.start()
elif int(pheaders['expected']):
event.eventname = 'FINISHED'
else:
event.eventname = 'FAILED'
session = Session()
session.add(event)
session.commit()
childutils.listener.ok(self.stdout)
sys.stderr.flush()
开发者ID:brandscreen,项目名称:supervisor-joblogger,代码行数:34,代码来源:joblogger.py
示例5: runforever
def runforever(self, test=False):
prev_current_time = int(time.time())
while 1:
gevent.sleep(1)
# we explicitly use self.stdin, self.stdout, and self.stderr
# instead of sys.* so we can unit test this code
headers, payload = self.listener_nodemgr.wait(
self.stdin, self.stdout)
# self.stderr.write("headers:\n" + str(headers) + '\n')
# self.stderr.write("payload:\n" + str(payload) + '\n')
pheaders, pdata = childutils.eventdata(payload + '\n')
# self.stderr.write("pheaders:\n" + str(pheaders)+'\n')
# self.stderr.write("pdata:\n" + str(pdata))
# check for process state change events
if headers['eventname'].startswith("PROCESS_STATE"):
self.event_process_state(pheaders, headers)
# check for flag value change events
if headers['eventname'].startswith("PROCESS_COMMUNICATION"):
self.event_process_communication(pdata)
# do periodic events
if headers['eventname'].startswith("TICK_60"):
self.database_periodic()
prev_current_time = self.event_tick_60(prev_current_time)
self.listener_nodemgr.ok(self.stdout)
开发者ID:lebauce,项目名称:contrail-controller,代码行数:27,代码来源:database_event_manager.py
示例6: handle_event
def handle_event(payload):
'''
Execute the post script when the monitored events happen
'''
pheaders, pdata = childutils.eventdata(payload+'\n')
name_list = pheaders['groupname'].split('--')
if len(name_list) == 3:
service, cluster, job = name_list
else:
return None
childutils.pcomm.stderr(childutils.get_asctime()+' Process %(processname)s '
'in group %(groupname)s exited from state %(from_state)s. '
'Now execute the post script.\n' % pheaders)
supervisor_config_path = '%s/../supervisord.conf' % os.path.dirname(__file__)
if not os.path.exists(supervisor_config_path):
childutils.pcomm.stderr('Cannot find the config file: supervisord.conf.\n')
parser = ConfigParser.SafeConfigParser()
parser.read([supervisor_config_path])
sys.path.append('%s/../deployment' % os.path.dirname(__file__))
from rpcinterface import DEFAULT_APP_ROOT
app_root = parser.get('rpcinterface:deployment', 'app_root', DEFAULT_APP_ROOT)
service_root = '%s/%s/%s/%s' % (app_root, service, cluster, job)
if not os.path.exists('%s/post.sh' % service_root):
childutils.pcomm.stderr('No post.sh for %s found.\n' % service)
return None
cmd = ['/bin/bash', '%s/post.sh' % service_root]
subprocess.call(cmd)
开发者ID:askyer,项目名称:minos,代码行数:33,代码来源:process_exit_monitor.py
示例7: run
def run(self):
try:
while True:
# get the supervisor event
headers, payload = childutils.listener.wait(sys.stdin, sys.stdout)
pheaders, pdata = childutils.eventdata(payload+'\n')
logging.debug((repr(headers), repr(pheaders), repr(pdata)))
# # did a broker die?
# if headers.get('eventname') == 'PROCESS_STATE_EXITED':
# if pheaders.get('processname') in self.watching:
# # the broker died. tell supervisor to restart
# logging.debug('Restarting supervisord')
# i = childutils.getRPCInterface(os.environ)
# i.supervisor.restart()
# # in theory we never get here...
# publish the event
self.socket.send(dumps((headers, pheaders, pdata)))
# ack to supervisor that we did something
childutils.listener.ok(sys.stdout)
except:
logging.exception('Event listener blew up')
finally:
self.socket.close()
self.context.term()
开发者ID:7footmoustache,项目名称:xodb,代码行数:27,代码来源:events.py
示例8: get_process_state_change_msg
def get_process_state_change_msg(self, headers, payload):
pheaders, pdata = childutils.eventdata(payload + "\n")
if int(pheaders["expected"]):
return None
txt = "[%(groupname)s:%(processname)s](%(pid)s) exited unexpectedly" % pheaders
return "%s %s" % (txt, childutils.get_asctime(self.now))
开发者ID:faheem-cliqz,项目名称:superlance,代码行数:8,代码来源:crashsms.py
示例9: get_process_state_change_msg
def get_process_state_change_msg(self, headers, payload):
logging.debug('at the start of the get_process_state_change_msg.')
pheaders, pdata = childutils.eventdata(payload + '\n')
logging.debug('pheaders = %s', pheaders)
logging.debug('pdata = %s', pdata)
txt = 'Process %(groupname)s:%(processname)s (pid %(pid)s) stopped unexpectedly with a state of %(from_state)s' % pheaders
logging.debug('The text = %s', txt)
return txt
开发者ID:ogg1e,项目名称:superzulip,代码行数:8,代码来源:superzulip.py
示例10: main
def main():
rpcinterface = childutils.getRPCInterface(os.environ)
while 1:
headers, payload = childutils.listener.wait()
if headers["eventname"].startswith("PROCESS_COMMUNICATION"):
pheaders, pdata = childutils.eventdata(payload)
pname = "%s:%s" % (pheaders["processname"], pheaders["groupname"])
rpcinterface.supervisor.sendProcessStdin(pname, "Got it yo\n")
childutils.listener.ok()
开发者ID:B-Rich,项目名称:supervisor,代码行数:9,代码来源:loop_listener.py
示例11: get_process_state_change_msg
def get_process_state_change_msg(self, headers, payload):
pheaders, pdata = childutils.eventdata(payload+'\n')
if int(pheaders['expected']):
return None
txt = 'Process %(groupname)s:%(processname)s (pid %(pid)s) died \
unexpectedly' % pheaders
return '%s -- %s' % (childutils.get_asctime(self.now), txt)
开发者ID:ParthKolekar,项目名称:superlance,代码行数:9,代码来源:crashmailbatch.py
示例12: get_process_state_change_msg
def get_process_state_change_msg(self, headers, payload):
pheaders, pdata = childutils.eventdata(payload+'\n')
if int(pheaders['expected']):
return None
txt = '[%(groupname)s:%(processname)s](%(pid)s) exited unexpectedly' \
% pheaders
return '%s %s' % (txt, childutils.get_asctime(self.now))
开发者ID:ParthKolekar,项目名称:superlance,代码行数:9,代码来源:crashsms.py
示例13: main
def main():
while 1:
headers, payload = childutils.listener.wait()
if headers['eventname'].startswith('PROCESS_STATE_RUNNING'):
pheaders, pdata = childutils.eventdata(payload+'\n')
if pheaders['processname'] == "postgresql":
os.system("supervisorctl start jon")
break
childutils.listener.ok()
开发者ID:djeremiah,项目名称:dockerfiles,代码行数:10,代码来源:startjon.py
示例14: runforever
def runforever(self, test=False):
while 1:
# we explicitly use self.stdin, self.stdout, and self.stderr
# instead of sys.* so we can unit test this code
headers, payload = childutils.listener.wait(self.stdin, self.stdout)
pheaders, pdata = childutils.eventdata(payload+'\n')
#self.stderr.write(headers['eventname'] + '\n')
#self.stderr.flush()
if headers['eventname'] == 'PROCESS_STATE_UNKNOWN':
msg = ('Process %(processname)s in group %(groupname)s UNKNOWN from state %(from_state)s' % pheaders)
subject = ' %s UNKNOWN at %s' % (pheaders['processname'], childutils.get_asctime())
# elif headers['eventname'] == 'PROCESS_STATE_STARTING':
# msg = ('Process %(processname)s in group %(groupname)s STARTING from state %(from_state)s' % pheaders)
# subject = ' %s STARTING at %s' % (pheaders['processname'], childutils.get_asctime())
elif headers['eventname'] == 'PROCESS_STATE_RUNNING':
msg = ('Process %(processname)s in group %(groupname)s RUNNING (pid %(pid)s) from state %(from_state)s' % pheaders)
subject = ' %s RUNNING at %s' % (pheaders['processname'], childutils.get_asctime())
elif headers['eventname'] == 'PROCESS_STATE_BACKOFF':
msg = ('Process %(processname)s in group %(groupname)s BACKOFF from state %(from_state)s' % pheaders)
subject = ' %s BACKOFF at %s' % (pheaders['processname'], childutils.get_asctime())
# elif headers['eventname'] == 'PROCESS_STATE_STOPPING':
# msg = ('Process %(processname)s in group %(groupname)s STOPPING from state %(from_state)s' % pheaders)
# subject = ' %s STOPPING at %s' % (pheaders['processname'], childutils.get_asctime())
elif headers['eventname'] == 'PROCESS_STATE_STOPPED':
msg = ('Process %(processname)s in group %(groupname)s STOPPED from state %(from_state)s' % pheaders)
subject = ' %s STOPPED at %s' % (pheaders['processname'], childutils.get_asctime())
elif headers['eventname'] == 'PROCESS_STATE_EXITED':
msg = ('Process %(processname)s in group %(groupname)s EXITED unexpectedly (pid %(pid)s) from state %(from_state)s' % pheaders)
subject = ' %s EXITED at %s' % (pheaders['processname'], childutils.get_asctime())
elif headers['eventname'] == 'PROCESS_STATE_FATAL':
msg = ('Process %(processname)s in group %(groupname)s FATAL from state %(from_state)s' % pheaders)
subject = ' %s FATAL at %s' % (pheaders['processname'], childutils.get_asctime())
else:
childutils.listener.ok(self.stdout)
if test:
self.stderr.write('non-exited event\n')
self.stderr.flush()
break
continue
if self.optionalheader:
subject = self.optionalheader + ':' + subject
self.stderr.write('unexpected exit, mailing\n')
self.stderr.flush()
self.mail(self.email, subject, msg)
childutils.listener.ok(self.stdout)
if test:
break
开发者ID:YoannQueret,项目名称:ODR-tools,代码行数:55,代码来源:supermail.py
示例15: runforever
def runforever(self):
while True:
headers, payload = childutils.listener.wait(self.stdin, self.stdout)
if headers['eventname'] == 'PROCESS_STATE_EXITED':
pheaders, pdata = childutils.eventdata(payload+'\n')
if int(pheaders['expected']) == 0:
self.message = ('Process %(processname)s in group %(groupname)s exited '
'unexpectedly (pid %(pid)s) from state %(from_state)s' %
pheaders)
self.run()
childutils.listener.ok(self.stdout)
开发者ID:cool-shark,项目名称:crashxmpp,代码行数:11,代码来源:crashxmpp.py
示例16: runforever
def runforever(self, test=False):
prev_current_time = int(time.time())
while 1:
gevent.sleep(1)
# we explicitly use self.stdin, self.stdout, and self.stderr
# instead of sys.* so we can unit test this code
headers, payload = self.listener_nodemgr.wait(self.stdin, self.stdout)
#self.stderr.write("headers:\n" + str(headers) + '\n')
#self.stderr.write("payload:\n" + str(payload) + '\n')
pheaders, pdata = childutils.eventdata(payload+'\n')
#self.stderr.write("pheaders:\n" + str(pheaders)+'\n')
#self.stderr.write("pdata:\n" + str(pdata))
# check for process state change events
if headers['eventname'].startswith("PROCESS_STATE"):
self.event_process_state(pheaders, headers)
# check for addition / deletion of processes in the node.
# Tor Agent process can get added / deleted based on need.
self.update_current_process()
# check for flag value change events
if headers['eventname'].startswith("PROCESS_COMMUNICATION"):
self.event_process_communication(pdata)
# do periodic events
if headers['eventname'].startswith("TICK_60"):
os_nova_comp = self.process_state_db['openstack-nova-compute']
(os_nova_comp_state, error_value) = Popen("openstack-status | grep openstack-nova-compute | cut -d ':' -f2", shell=True, stdout=PIPE).communicate()
if (os_nova_comp_state.strip() == 'active'):
os_nova_comp_state = 'PROCESS_STATE_RUNNING'
if (os_nova_comp_state.strip() == 'dead'):
os_nova_comp_state = 'PROCESS_STATE_FATAL'
if (os_nova_comp_state.strip() == 'inactive'):
os_nova_comp_state = 'PROCESS_STATE_STOPPED'
if (os_nova_comp.process_state != os_nova_comp_state):
os_nova_comp.process_state = os_nova_comp_state.strip()
sys.stderr.write('Openstack Nova Compute status changed to:' + os_nova_comp.process_state + "\n")
if (os_nova_comp.process_state == 'PROCESS_STATE_RUNNING'):
os_nova_comp.start_time = str(int(time.time()*1000000))
os_nova_comp.start_count += 1
if (os_nova_comp.process_state == 'PROCESS_STATE_FATAL'):
os_nova_comp.exit_time = str(int(time.time()*1000000))
os_nova_comp.exit_count += 1
if (os_nova_comp.process_state == 'PROCESS_STATE_STOPPED'):
os_nova_comp.stop_time = str(int(time.time()*1000000))
os_nova_comp.stop_count += 1
self.process_state_db['openstack-nova-compute'] = os_nova_comp
self.send_process_state_db('vrouter_group')
else:
sys.stderr.write('Openstack Nova Compute status unchanged at:' + os_nova_comp.process_state + "\n")
self.process_state_db['openstack-nova-compute'] = os_nova_comp
prev_current_time = self.event_tick_60(prev_current_time)
self.listener_nodemgr.ok(self.stdout)
开发者ID:my76128,项目名称:contrail-controller,代码行数:54,代码来源:VrouterNodemgr.py
示例17: get_process_state_change_msg
def get_process_state_change_msg(self, headers, payload):
pheaders, pdata = childutils.eventdata(payload + "\n")
if int(pheaders["expected"]):
return None
txt = (
"Process %(groupname)s:%(processname)s (pid %(pid)s) died \
unexpectedly"
% pheaders
)
return "%s -- %s" % (childutils.get_asctime(self.now), txt)
开发者ID:heynemann,项目名称:superlance,代码行数:12,代码来源:crashmailbatch.py
示例18: runforever
def runforever(self, test=False):
while 1:
# we explicitly use self.stdin, self.stdout, and self.stderr
# instead of sys.* so we can unit test this code
headers, payload = childutils.listener.wait(
self.stdin, self.stdout)
if not headers['eventname'] == 'PROCESS_STATE_EXITED':
# do nothing with non-TICK events
childutils.listener.ok(self.stdout)
if test:
self.stderr.write('non-exited event\n')
self.stderr.flush()
break
continue
pheaders, pdata = childutils.eventdata(payload+'\n')
if int(pheaders['expected']):
childutils.listener.ok(self.stdout)
if test:
self.stderr.write('expected exit\n')
self.stderr.flush()
break
continue
msg = ('Process %(processname)s in group %(groupname)s exited '
'unexpectedly (pid %(pid)s) from state %(from_state)s' %
pheaders)
# Supervisor will inject the SUPERVISOR_SERVER_URL into each of the
# supervised processes, with the address (tcp, unix socket...) of the
# supervisor RPC server URL.
if os.environ.get('SUPERVISOR_SERVER_URL'):
# Get last lines from both stdout and stderr
stdout_tail = self.tail(pheaders['groupname'], pheaders['processname'], 'stdout', self.logtail)
stderr_tail = self.tail(pheaders['groupname'], pheaders['processname'], 'stderr', self.logtail)
msg = '%s\n\nLast lines from stdout:\n%s\n\nLast lines from stderr:\n%s' % (msg, stdout_tail, stderr_tail)
subject = ' %s crashed at %s' % (pheaders['processname'],
childutils.get_asctime())
if self.optionalheader:
subject = self.optionalheader + ':' + subject
self.stderr.write('unexpected exit, mailing\n')
self.stderr.flush()
self.mail(self.email, subject, msg)
childutils.listener.ok(self.stdout)
if test:
break
开发者ID:brouberol,项目名称:superlance,代码行数:52,代码来源:crashmail.py
示例19: get_process_state_change_msg
def get_process_state_change_msg(self, headers, payload):
pheaders, pdata = childutils.eventdata(payload + "\n")
txt = (
"Process %(groupname)s:%(processname)s failed to start too many \
times\n"
% pheaders
)
if self.stderr_lines:
txt += get_last_lines_of_process_stderr(pheaders, self.stderr_lines)
if self.stdout_lines:
txt += get_last_lines_of_process_stdout(pheaders, self.stdout_lines)
return "%s -- %s" % (childutils.get_asctime(self.now), txt)
开发者ID:hltbra,项目名称:superlance,代码行数:13,代码来源:fatalmailbatch.py
示例20: get_process_state_change_msg
def get_process_state_change_msg(self, headers, payload):
pheaders, pdata = childutils.eventdata(payload+'\n')
if int(pheaders['expected']):
return None
txt = 'Process %(groupname)s:%(processname)s (pid %(pid)s) died \
unexpectedly\n' % pheaders
if self.stderr_lines:
txt += get_last_lines_of_process_stderr(pheaders, self.stderr_lines)
if self.stdout_lines:
txt += get_last_lines_of_process_stdout(pheaders, self.stdout_lines)
return '%s -- %s' % (childutils.get_asctime(self.now), txt)
开发者ID:hltbra,项目名称:superlance,代码行数:13,代码来源:crashmailbatch.py
注:本文中的supervisor.childutils.eventdata函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论