示例#1
0
def launch_node(args: Namespace, chain_config: ChainConfig,
                endpoint: Endpoint) -> None:
    with chain_config.process_id_file('networking'):

        endpoint.connect()

        NodeClass = chain_config.node_class
        # Temporary hack: We setup a second instance of the PluginManager.
        # The first instance was only to configure the ArgumentParser whereas
        # for now, the second instance that lives inside the networking process
        # performs the bulk of the work. In the future, the PluginManager
        # should probably live in its own process and manage whether plugins
        # run in the shared plugin process or spawn their own.

        plugin_manager = setup_plugins(SharedProcessScope(endpoint))
        plugin_manager.prepare(args, chain_config)
        plugin_manager.broadcast(TrinityStartupEvent(args, chain_config))

        node = NodeClass(plugin_manager, chain_config)
        loop = node.get_event_loop()
        asyncio.ensure_future(handle_networking_exit(node, plugin_manager,
                                                     endpoint),
                              loop=loop)
        asyncio.ensure_future(node.run(), loop=loop)
        loop.run_forever()
        loop.close()
示例#2
0
def launch_node(args: Namespace, chain_config: ChainConfig) -> None:
    with chain_config.process_id_file('networking'):
        NodeClass = chain_config.node_class
        # Temporary hack: We setup a second instance of the PluginManager.
        # The first instance was only to configure the ArgumentParser whereas
        # for now, the second instance that lives inside the networking process
        # performs the bulk of the work. In the future, the PluginManager
        # should probably live in its own process and manage whether plugins
        # run in the shared plugin process or spawn their own.
        plugin_manager = setup_plugins()
        plugin_manager.broadcast(TrinityStartupEvent(args, chain_config))

        node = NodeClass(plugin_manager, chain_config)

        run_service_until_quit(node)
示例#3
0
def run_database_process(chain_config: ChainConfig, db_class: Type[BaseDB]) -> None:
    with chain_config.process_id_file('database'):
        base_db = db_class(db_path=chain_config.database_dir)

        manager = get_chaindb_manager(chain_config, base_db)
        server = manager.get_server()  # type: ignore

        def _sigint_handler(*args: Any) -> None:
            server.stop_event.set()

        signal.signal(signal.SIGINT, _sigint_handler)

        try:
            server.serve_forever()
        except SystemExit:
            server.stop_event.set()
            raise
示例#4
0
def run_database_process(chain_config: ChainConfig,
                         db_class: Type[BaseDB]) -> None:
    with chain_config.process_id_file('database'):
        base_db = db_class(db_path=chain_config.database_dir)

        serve_chaindb(chain_config, base_db)