<s> '''<STR_LIT>''' <EOL> from whirlwind . core . bootstrap import Bootstrap as WhirlwindBootstrap <EOL> import os , logging <EOL> import tornado . web , tornado . options <EOL> from tornado . options import options <EOL> from config import options_setup <EOL> from whirlwind . db . mongo import Mongo <EOL> from whirlwind . contrib . sockjs . router_connection import ConnectionLoader , RouterConnection <EOL> from whirlwind . contrib . sockjs . multiplex import MultiplexConnection <EOL> from sockjs . tornado import SockJSRouter <EOL> class Bootstrap ( WhirlwindBootstrap ) : <EOL> def __init__ ( self ) : <EOL> WhirlwindBootstrap . __init__ ( self ) <EOL> self . connection_router = None <EOL> def init_mongo ( self ) : <EOL> Mongo . create ( <EOL> host = options . db_host , <EOL> port = options . db_port <EOL> ) <EOL> def init_connection_router ( self ) : <EOL> connections = ConnectionLoader . load ( '<STR_LIT>' ) <EOL> for conn in connections : <EOL> RouterConnection . __endpoints__ [ conn [ <NUM_LIT:0> ] ] = conn [ <NUM_LIT:1> ] <EOL> router = MultiplexConnection . get ( ** RouterConnection . __endpoints__ ) <EOL> self . connection_router = SockJSRouter ( router , '<STR_LIT>' ) <EOL> def main ( self , path ) : <EOL> tornado . options . parse_config_file ( os . path . join ( path , '<STR_LIT>' ) ) <EOL> tornado . options . parse_command_line ( ) <EOL> self . init_mongo ( ) <EOL> url_routes = self . init_routes ( ) <EOL> self . init_connection_router ( ) <EOL> app_settings = { <EOL> "<STR_LIT>" : options . static_path , <EOL> "<STR_LIT>" : options . cookie_secret , <EOL> "<STR_LIT>" : options . login_url <EOL> } <EOL> self . application = tornado . web . Application ( <EOL> self . connection_router . urls + url_routes , <EOL> ** app_settings <EOL> ) <EOL> logging . getLogger ( ) . setLevel ( logging . DEBUG ) <EOL> logging . info ( "<STR_LIT>" ) <EOL> self . application . listen ( options . port ) <EOL> tornado . ioloop . IOLoop . instance ( ) . start ( ) <EOL> @ staticmethod <EOL> def run ( path ) : <EOL> bootstrap = Bootstrap ( ) <EOL> bootstrap . main ( path ) </s>
