Beispiel #1
0
 class Meta(TokenModel.Meta):
     db_table = 'archived_tokens_%s' % master_name()
Beispiel #2
0
 class Meta(TokenModel.Meta):
     # Table name is suffixed with master name.  This way multiple masters
     # can store their state in the same database.
     db_table = 'active_tokens_%s' % master_name()
Beispiel #3
0
 def get_table_name():
     return 'archived_tokens_%s' % master_name()
Beispiel #4
0
 class Meta:
     db_table = 'cached_data_%s' % master_name()
Beispiel #5
0
 def get_table_name():
     return 'active_tokens_%s' % master_name()
Beispiel #6
0
def main():
    _register_signal_listener()

    parser = argparse.ArgumentParser(
        description='Start Pinball master and workers.')
    parser.add_argument(
        '-c',
        '--config_file',
        dest='config_file',
        required=True,
        help='full path to the pinball setting configure file')
    parser.add_argument(
        '-m',
        '--mode',
        dest='mode',
        choices=['master', 'scheduler', 'workers', 'ui'],
        default='master',
        help='execution mode')

    options = parser.parse_args(sys.argv[1:])
    PinballConfig.parse(options.config_file)

    if hasattr(PinballConfig, 'MASTER_NAME') and PinballConfig.MASTER_NAME:
        master_name(PinballConfig.MASTER_NAME)
    _pinball_imports()
    if PinballConfig.UI_HOST:
        emailer = Emailer(PinballConfig.UI_HOST, PinballConfig.UI_PORT)
    else:
        emailer = Emailer(socket.gethostname(), PinballConfig.UI_PORT)

    if options.mode == 'ui':
        hostport = '%s:%d' % (socket.gethostname(), PinballConfig.UI_PORT)
        cache_thread.start_cache_thread(DbStore())
        if not PinballConfig.UI_HOST:
            hostport = 'localhost:%d' % PinballConfig.UI_PORT

        # Disable reloader to prevent auto refresh on file changes.  The
        # problem with auto-refresh is that it starts multiple processes.  Some
        # of those processes will become orphans if we kill the UI in a wrong
        # way.
        management.call_command('runserver', hostport, interactive=False,
                                use_reloader=False)
        return

    factory = Factory(master_hostname=PinballConfig.MASTER_HOST,
                      master_port=PinballConfig.MASTER_PORT)
    threads = []
    if options.mode == 'master':
        factory.create_master(DbStore())
    elif options.mode == 'scheduler':
        threads.append(_create_scheduler(factory, emailer))
    else:
        assert options.mode == 'workers'
        if PinballConfig.UI_HOST:
            emailer = Emailer(PinballConfig.UI_HOST, PinballConfig.UI_PORT)
        else:
            emailer = Emailer(socket.gethostname(), PinballConfig.UI_PORT)
        threads = _create_workers(PinballConfig.WORKERS, factory, emailer)

    try:
        if options.mode == 'master':
            factory.run_master_server()
        else:
            _wait_for_threads(threads)
    except KeyboardInterrupt:
        LOG.info('Exiting')
        sys.exit()
Beispiel #7
0
 def get_table_name():
     return 'cached_data_%s' % master_name()
Beispiel #8
0
 def get_table_name():
     return 'archived_tokens_%s' % master_name()
Beispiel #9
0
 def get_table_name():
     return 'active_tokens_%s' % master_name()
Beispiel #10
0
 def get_table_name():
     return 'cached_data_%s' % master_name()
Beispiel #11
0
 class Meta(TokenModel.Meta):
     app_label = 'persistence'
     db_table = 'archived_tokens_%s' % master_name()
Beispiel #12
0
 class Meta:
     app_label = 'persistence'
     db_table = 'cached_data_%s' % master_name()