Пример #1
0
def start(args):
    resource.register('log', LogFactory())
    scripts.select_json()

    # Load and activate the database configuration
    datastore = resource.register('datastore', RedisStore(args.db_host, args.db_port, args.db_num, args.db_pw), True)
    db_config = datastore.load_object(args.config_id, dbconfig.Config)
    config_values = config.activate(db_config.section_values)

    resource.register('dispatcher', event, True)
    resource.register('perm', permissions, True)

    web_server = WebServer()

    app_setup = import_module('{}.setup'.format(args.app_id))
    app_setup.start_engine(args, config_values, web_server)

    resource.register('user_manager', UserManager())
    resource.register('session_manager', SessionManager())
    resource.register('instance_manager', InstanceManager())
    resource.register('email_sender', EmailSender())
    resource.register('channel_service', ChannelService())
    resource.register('friend_service', FriendService())
    resource.register('message_service', MessageService())
    resource.register('player_list_service', PlayerListService())
    resource.register('login_notify_service', AnyLoginService())
    resource.register('edit_notify_service', EditUpdateService(), True)

    context_post_init()

    main_router.init(web_server)
    edit_router.init(web_server)

    web_server.add(r"/", RedirectHandler, url="/webclient/lampost.html")
    web_server.add(r"/webclient/(.*)", StaticFileHandler, path="webclient")
    web_server.start_service(args.port, args.server_interface)

    IOLoop.instance().start()
Пример #2
0
def new_setup(args):

    resource.register('log', LogFactory())
    scripts.select_json()

    # Initialize the database, flush if requested
    datastore = resource.register('datastore', RedisStore(args.db_host, args.db_port, args.db_num, args.db_pw), True)
    if args.flush:
        db_num = datastore.pool.connection_kwargs['db']
        if db_num == args.db_num:
            warn("Flushing database {}", db_num)
            datastore.redis.flushdb()
        else:
            print("Error:  DB Numbers do not match")
            return

    db_config = datastore.load_object(args.config_id, 'config')
    if db_config:
        print("Error:  This instance is already set up")
        return

    # Load config yaml files and create the database configuration
    config_yaml = config.load_yaml(args.config_dir)
    db_config = dbconfig.create(args.config_id, config_yaml, True)
    config_values = config.activate(db_config.section_values)

    # Initialize core services needed by the reset of the setup process
    resource.register('dispatcher', event, True)
    perm = resource.register('perm', permissions, True)
    perm._post_init()

    app_setup = import_module('{}.setup'.format(args.app_id))
    first_player = app_setup.first_time_setup(args, datastore, config_values)

    user_manager = UserManager()
    user = user_manager.create_user(args.imm_account, args.imm_password)
    player = user_manager.attach_player(user, first_player)
    perm.update_immortal_list(player)