async def main(): root_path = DEFAULT_ROOT_PATH net_config = load_config(root_path, "config.yaml") config = load_config_cli(root_path, "config.yaml", "introducer") initialize_logging("Introducer %(name)-21s", config["logging"]) log = logging.getLogger(__name__) setproctitle("chia_introducer") introducer = Introducer(config) ping_interval = net_config.get("ping_interval") network_id = net_config.get("network_id") assert ping_interval is not None assert network_id is not None server = ChiaServer(config["port"], introducer, NodeType.INTRODUCER, ping_interval, network_id) introducer.set_server(server) _ = await server.start_server(None, config) asyncio.get_running_loop().add_signal_handler(signal.SIGINT, server.close_all) asyncio.get_running_loop().add_signal_handler(signal.SIGTERM, server.close_all) await server.await_closed() log.info("Introducer fully closed.")
async def main(): introducer = Introducer() host, port = parse_host_port(introducer) server = ChiaServer(port, introducer, NodeType.INTRODUCER) introducer.set_server(server) _ = await server.start_server(host, None) asyncio.get_running_loop().add_signal_handler(signal.SIGINT, server.close_all) asyncio.get_running_loop().add_signal_handler(signal.SIGTERM, server.close_all) await server.await_closed()
def service_kwargs_for_introducer(root_path=DEFAULT_ROOT_PATH): service_name = "introducer" config = load_config_cli(root_path, "config.yaml", service_name) introducer = Introducer( config["max_peers_to_send"], config["recent_peer_threshold"] ) async def start_callback(): await introducer._start() def stop_callback(): introducer._close() async def await_closed_callback(): await introducer._await_closed() kwargs = dict( root_path=root_path, api=introducer, node_type=NodeType.INTRODUCER, advertised_port=config["port"], service_name=service_name, server_listen_ports=[config["port"]], start_callback=start_callback, stop_callback=stop_callback, await_closed_callback=await_closed_callback, ) return kwargs
async def setup_introducer(port, dic={}): net_config = load_config(root_path, "config.yaml") ping_interval = net_config.get("ping_interval") network_id = net_config.get("network_id") config = load_config(root_path, "config.yaml", "introducer") introducer = Introducer(config) assert ping_interval is not None assert network_id is not None server = ChiaServer( port, introducer, NodeType.INTRODUCER, ping_interval, network_id, bt.root_path, config, ) _ = await server.start_server(None) yield (introducer, server) server.close_all() await server.await_closed()
async def setup_introducer(port, dic={}): net_config = load_config(root_path, "config.yaml") ping_interval = net_config.get("ping_interval") network_id = net_config.get("network_id") config = load_config(root_path, "config.yaml", "introducer") introducer = Introducer(config["max_peers_to_send"], config["recent_peer_threshold"]) assert ping_interval is not None assert network_id is not None server = ChiaServer( port, introducer, NodeType.INTRODUCER, ping_interval, network_id, bt.root_path, config, f"introducer_server_{port}", ) _ = await start_server(server) yield (introducer, server) _.close() server.close_all() await server.await_closed()
async def main(): config = load_config_cli("config.yaml", "introducer") initialize_logging("Introducer %(name)-21s", config["logging"]) log = logging.getLogger(__name__) setproctitle("chia_introducer") introducer = Introducer(config) server = ChiaServer(config["port"], introducer, NodeType.INTRODUCER) introducer.set_server(server) _ = await server.start_server(config["host"], None) asyncio.get_running_loop().add_signal_handler(signal.SIGINT, server.close_all) asyncio.get_running_loop().add_signal_handler(signal.SIGTERM, server.close_all) await server.await_closed() log.info("Introducer fully closed.")
def service_kwargs_for_introducer(root_path=DEFAULT_ROOT_PATH): service_name = "introducer" config = load_config_cli(root_path, "config.yaml", service_name) introducer = Introducer(config["max_peers_to_send"], config["recent_peer_threshold"]) kwargs = dict( root_path=root_path, api=introducer, node_type=NodeType.INTRODUCER, advertised_port=config["port"], service_name=service_name, server_listen_ports=[config["port"]], ) return kwargs
def service_kwargs_for_introducer( root_path: pathlib.Path, config: Dict, ) -> Dict: api = Introducer(config["max_peers_to_send"], config["recent_peer_threshold"]) kwargs = dict( root_path=root_path, api=api, node_type=NodeType.INTRODUCER, advertised_port=config["port"], service_name=SERVICE_NAME, server_listen_ports=[config["port"]], ) return kwargs
async def setup_introducer(port): config = load_config(bt.root_path, "config.yaml", "introducer") api = Introducer(config["max_peers_to_send"], config["recent_peer_threshold"]) started = asyncio.Event() async def start_callback(): await api._start() nonlocal started started.set() def stop_callback(): api._close() async def await_closed_callback(): await api._await_closed() service = Service( root_path=bt.root_path, api=api, node_type=NodeType.INTRODUCER, advertised_port=port, service_name="introducer", server_listen_ports=[port], auth_connect_peers=False, start_callback=start_callback, stop_callback=stop_callback, await_closed_callback=await_closed_callback, parse_cli_args=False, ) run_task = asyncio.create_task(service.run()) await started.wait() yield api, api.server service.stop() await run_task