|
@@ -13,17 +13,23 @@ struct Args {
|
|
|
|
|
|
pub async fn cmd() {
|
|
|
let args = Args::parse();
|
|
|
- match init_config(args.config).await {
|
|
|
- Ok(()) => {
|
|
|
- let emu = Arc::new(ems::emu::emu::Emu::new().await);
|
|
|
- let _ = emu.run().await;
|
|
|
- }
|
|
|
- Err(e) => {
|
|
|
- eprintln!("配置加载失败: {}", e.to_string());
|
|
|
- }
|
|
|
+ let result = init_system(args.config).await;
|
|
|
+ if let Err(e) = result {
|
|
|
+ eprintln!("系统初始化失败: {}", e.to_string());
|
|
|
+ } else {
|
|
|
+ let emu = Arc::new(ems::emu::emu::Emu::new().await);
|
|
|
+ let _ = emu.run().await;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/// 初始化系统资源以及配置
|
|
|
+async fn init_system(config_path: String) -> anyhow::Result<()> {
|
|
|
+ init_config(config_path).await?;
|
|
|
+ // let rabbitmq = RabbitMQ::new().await?;
|
|
|
+ // MQ.get_or_init(|| rabbitmq);
|
|
|
+ Ok(())
|
|
|
+}
|
|
|
+
|
|
|
/// 配置载入内存
|
|
|
async fn init_config(config_path: String) -> anyhow::Result<()> {
|
|
|
let content = read_to_string(config_path).await?;
|