Forráskód Böngészése

启动参数修改

hl 1 éve
szülő
commit
e87b1cde8a
2 módosított fájl, 12 hozzáadás és 13 törlés
  1. 2 2
      global/src/params.rs
  2. 10 11
      src/main.rs

+ 2 - 2
global/src/params.rs

@@ -53,7 +53,7 @@ pub struct Params {
     // 运行模式 0.正常策略运行, 1.清理挂单及仓位
     pub run_mode: i8,
     // 机器人id
-    pub robot_id: String,
+    pub check_id: String,
 }
 
 impl Params {
@@ -101,7 +101,7 @@ impl Params {
             log_level: "info".to_string(),
             port: call_port,
             run_mode: 0,
-            robot_id: "-1".to_string()
+            check_id: "-1".to_string()
         };
         Ok(params)
     }

+ 10 - 11
src/main.rs

@@ -47,7 +47,7 @@ fn read_params_json() -> Params {
     let mut call_port = 5555;
     // 运行模式 0.正常策略运行, 1.清理挂单及仓位
     let mut run_mode = 0;
-    let mut robot_id= "-1".to_string();
+    let mut check_id = "-1".to_string();
 
     let args: Vec<String> = std::env::args().collect();
 
@@ -82,27 +82,27 @@ fn read_params_json() -> Params {
             }
         }
 
-        // Check for the --port argument and assign its value.
-        if arg.starts_with("--robot_id=") {
+        //上报ID
+        if arg.starts_with("--check_id=") {
             let parts: Vec<&str> = arg.split('=').collect();
             if parts.len() == 2 {
-                robot_id = parts[1].to_string();
+                check_id = parts[1].to_string();
             } else {
-                error!("启动失败,机器人id参数格式设置错误 --robot_id=xxx!");
-                panic!("启动失败,机器人id参数格式设置错误 --robot_id=xxx!");
+                error!("启动失败,回执单id参数格式设置错误 --check_id=xxx!");
+                panic!("启动失败,回执单id参数格式设置错误 --check_id=xxx!");
             }
         }
     }
     println!("通讯端口:{}, 配置文件路径:{}", call_port, path);
     let mut params = Params::new_json(path, call_port).unwrap();
-    if run_mode == 1{
+    if run_mode == 1 {
         params.run_mode = 1;
-        if robot_id == "-1" {
+        if check_id == "-1" {
             error!("启动失败,缺少机器人id参数!");
             panic!("启动失败,缺少机器人id参数!");
         }
     }
-    params.robot_id = robot_id;
+    params.check_id = check_id;
     return params;
 }
 
@@ -142,7 +142,7 @@ async fn main() {
 
     // ws退出程序
     let ws_running = Arc::new(AtomicBool::new(true));
-    if params.run_mode == 1{
+    if params.run_mode == 1 {
         // core初始化动作
         let mut core_arc = clear_core_libs::init(params.clone(), ws_running.clone(), running.clone(), cci_arc.clone()).await;
         info!("开始执行清仓程序");
@@ -176,5 +176,4 @@ async fn main() {
         // 强制退出
         std::process::exit(0);
     }
-
 }