#NEWLINE# def setup( config_options ) : #NEWLINE# #INDENT# '\n    Args:\n        config_options_options: The options passed to Synapse. Usually\n            `sys.argv[1:]`.\n\n    Returns:\n        HomeServer\n    ' #NEWLINE# try : #NEWLINE# #INDENT# config = HomeServerConfig . load_config ( 'Synapse Homeserver' , config_options , generate_section = 'Homeserver' ) #NEWLINE# #UNINDENT# except ConfigError as e : #NEWLINE# #INDENT# sys . stderr . write ( ( ( '\n' + e . message ) + '\n' ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# if ( not config ) : #NEWLINE# #INDENT# sys . exit ( 0 ) #NEWLINE# #UNINDENT# config . setup_logging ( ) #NEWLINE# check_requirements ( config ) #NEWLINE# version_string = get_version_string ( ) #NEWLINE# logger . info ( 'Server hostname: %s' , config . server_name ) #NEWLINE# logger . info ( 'Server version: %s' , version_string ) #NEWLINE# events . USE_FROZEN_DICTS = config . use_frozen_dicts #NEWLINE# tls_server_context_factory = context_factory . ServerContextFactory ( config ) #NEWLINE# database_engine = create_engine ( config ) #NEWLINE# config . database_config [ 'args' ] [ 'cp_openfun' ] = database_engine . on_new_connection #NEWLINE# hs = SynapseHomeServer ( config . server_name , db_config = config . database_config , tls_server_context_factory = tls_server_context_factory , config = config , content_addr = config . content_addr , version_string = version_string , database_engine = database_engine ) #NEWLINE# logger . info ( 'Preparing database: %s...' , config . database_config [ 'name' ] ) #NEWLINE# try : #NEWLINE# #INDENT# db_conn = hs . get_db_conn ( ) #NEWLINE# database_engine . prepare_database ( db_conn ) #NEWLINE# hs . run_startup_checks ( db_conn , database_engine ) #NEWLINE# db_conn . commit ( ) #NEWLINE# #UNINDENT# except UpgradeDatabaseException : #NEWLINE# #INDENT# sys . stderr . write ( '\nFailed to upgrade database.\nHave you checked for version specific instructions in UPGRADES.rst?\n' ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# logger . info ( 'Database prepared in %s.' , config . database_config [ 'name' ] ) #NEWLINE# hs . setup ( ) #NEWLINE# hs . start_listening ( ) #NEWLINE# def start( ) : #NEWLINE# #INDENT# hs . get_pusherpool ( ) . start ( ) #NEWLINE# hs . get_state_handler ( ) . start_caching ( ) #NEWLINE# hs . get_datastore ( ) . start_profiling ( ) #NEWLINE# hs . get_datastore ( ) . start_doing_background_updates ( ) #NEWLINE# hs . get_replication_layer ( ) . start_get_pdu_cache ( ) #NEWLINE# #UNINDENT# reactor . callWhenRunning ( start ) #NEWLINE# return hs