Пример #1
0
def execute_all():
    component_facts = get_all_facts('kropotkin', 'component_deployed',
                                    {'location': THIS_MACHINE})
    subscription_facts = []
    for f in get_all_facts('kropotkin', 'factspace', {}):
        subscription_facts += get_all_facts(f['name'], 'subscription', {})

    for f in component_facts:
        if f['name'] != 'executioner':
            execute_pid(f['identifier'])
    for f in subscription_facts:
        pid = extract_local_process(f['queue'])
        if pid is not None:
            execute_pid(pid)
Пример #2
0
 def __init__(self, factspace, type_, criteria):
     self.factspace = factspace
     self.type_ = type_
     self.criteria = criteria
     subscribe(factspace, 'fact', type_)
     facts = get_all_facts(factspace, type_, criteria)
     self.count = 0 if facts is None else len(facts)
Пример #3
0
    if bytes_to_read == 0:
        return

    with open(log_file.path, 'r') as f:
        f.seek(-bytes_to_read, SEEK_END)
        log_data = f.read(MAX_FACT_SIZE)
        content = {'component': log_file.component,
                   'type':      log_file.type,
                   'file':      log_file.path,
                   'data':      log_data}
        if not store_fact('kropotkin', 'log_data', content):
            stderr.write("Could not store log_data\n")
        log_file.position += len(log_data)

subscribe('kropotkin', 'fact', 'component_deployed')
component_facts = get_all_facts('kropotkin', 'component_deployed', {})
map(store_component_log_files, filter(should_check_component, component_facts))

while True:
    target_end = time() + POLL_INTERVAL

    component_fact = get_next_fact_noblock('kropotkin', 'component_deployed')
    if component_fact and should_check_component(component_fact):
        store_component_log_files(component_fact)

    map(check_log_file, LOG_FILES)

    time_left = target_end - time()
    if time_left > 0:
        sleep(time_left)