Exemplo n.º 1
0
def create_proc_table(manager):
    for deployment in config.deployments():
        if deployment.get('enabled', True):
            name = deployment['name']
            db_deployment, new = db.get_or_create_deployment(name)
            for exchange in deployment.get('topics').keys():
                stats = manager.dict()
                proc_info = dict(process=None,
                                 pid=0,
                                 deployment=deployment,
                                 deploy_id=db_deployment.id,
                                 exchange=exchange,
                                 stats=stats)
                processes[(name, exchange)] = proc_info
Exemplo n.º 2
0
def create_proc_table(manager):
    for deployment in config.deployments():
        if deployment.get('enabled', True):
            name = deployment['name']
            db_deployment, new = db.get_or_create_deployment(name)
            for exchange in deployment.get('topics').keys():
                stats = manager.dict()
                proc_info = dict(process=None,
                                 pid=0,
                                 deployment=deployment,
                                 deploy_id=db_deployment.id,
                                 exchange=exchange,
                                 stats=stats)
                processes[(name, exchange)] = proc_info
Exemplo n.º 3
0
def kill_time(signal, frame):
    log_listener.end()
    print "dying ..."
    for process in processes:
        process.terminate()
    print "rose"
    for process in processes:
        process.join()
    print "bud"
    sys.exit(0)


if __name__ == '__main__':
    log_listener = stacklog.LogListener(_get_parent_logger()).start()
    for deployment in config.deployments():
        if deployment.get('enabled', True):
            db_deployment, new = db.get_or_create_deployment(deployment['name'])
            # NOTE (apmelton)
            # Close the connection before spinning up the child process,
            # otherwise the child process will attempt to use the connection
            # the parent process opened up to get/create the deployment.
            close_connection()
            for exchange in deployment.get('topics').keys():
                process = Process(target=worker.run, args=(deployment,
                                                           db_deployment.id,
                                                           exchange,))
                process.daemon = True
                process.start()
                processes.append(process)
    signal.signal(signal.SIGINT, kill_time)
Exemplo n.º 4
0
def kill_time(signal, frame):
    print "dying ..."
    for process in processes:
        process.terminate()
    print "rose"
    for process in processes:
        process.join()
    log_listener.end()
    print "bud"
    sys.exit(0)


if __name__ == '__main__':
    log_listener = stacklog.LogListener(_get_parent_logger())
    log_listener.start()
    for deployment in config.deployments():
        if deployment.get('enabled', True):
            db_deployment, new = db.get_or_create_deployment(
                deployment['name'])
            # NOTE (apmelton)
            # Close the connection before spinning up the child process,
            # otherwise the child process will attempt to use the connection
            # the parent process opened up to get/create the deployment.
            close_connection()
            for exchange in deployment.get('topics').keys():
                process = Process(target=worker.run,
                                  args=(
                                      deployment,
                                      db_deployment.id,
                                      exchange,
                                  ))