当前位置: 首页 > 工具软件 > libra-server > 使用案例 >

libra启动流程

暴乐邦
2023-12-01

libra启动流程

libra 启动流程分两步:启动libraSwarm和交互客户端(可选)

LibraSwarm启动流程

libra启动分4步:

  • 生成libra 配置
  • node启动
  • 等待node启动完成
  • 等待node连接成功
    libra_swarm/main.rs:main ->LibraSwarm::launch_swarm-> LibraSwarm::launch_swarm_attempt

libraSwarm配置生成

let config = config_builder.build().unwrap()

node启动

LibraNode::launch {

let mut node = node_command
.spawn() // 启动子进程 调用 libra_node/main.rs:main

}

生成 配置

executable_helpers::helpers::setup_executable

设置环境,启动服务

libra_node::main_node::setup_environment {

let mut instant = Instant::now();
//启动存储服务
let storage = start_storage_service(&node_config);
debug!(
“Storage service started in {} ms”,
instant.elapsed().as_millis()
);
//启动执行组件
instant = Instant::now();
let execution = ServerHandle::setup(setup_executor(&node_config));
debug!(
“Execution service started in {} ms”,
instant.elapsed().as_millis()
);
//启动网络服务
instant = Instant::now();
let (
(mempool_network_sender, mempool_network_events),
(consensus_network_sender, consensus_network_events),
network_runtime,
) = setup_network(&node_config);
debug!(“Network started in {} ms”, instant.elapsed().as_millis());
//启动AC
instant = Instant::now();
let (ac_server, ac_client) = setup_ac(&node_config);
let ac = ServerHandle::setup(ac_server);
debug!(“AC started in {} ms”, instant.elapsed().as_millis());
//启动内存池
instant = Instant::now();
let mempool =
MempoolRuntime::bootstrap(&node_config, mempool_network_sender, mempool_network_events);
debug!(“Mempool started in {} ms”, instant.elapsed().as_millis());

let debug_if = ServerHandle::setup(setup_debug_interface(&node_config));
// 启动度量服务
let metrics_port = node_config.debug_interface.metrics_server_port;
let metric_host = node_config.debug_interface.address.clone();
thread::spawn(move || metric_server::start_server(metric_host, metrics_port));
//启动一致性服务
instant = Instant::now();
let mut consensus_provider = make_consensus_provider(
&node_config,
consensus_network_sender,
consensus_network_events,
);
consensus_provider
.start()
.expect(“Failed to start consensus. Can’t proceed.”);
debug!(“Consensus started in {} ms”, instant.elapsed().as_millis());

}

注册钩子信号

register_signals(Arc::clone(&term))

等待node启动完成

swarm.wait_for_startup()?;

等待node连接成功

swarm.wait_for_connectivity()?;

交互Client启动(配置可选)

libra_swarm/main.rs:main->client::InteractiveClient::new_with_inherit_io

 类似资料: