Browse Source

新增-新策略对应 获取机器人状态接口

hl 5 months ago
parent
commit
c9ecd1e37f
2 changed files with 28 additions and 17 deletions
  1. 14 14
      src/robot.js
  2. 14 3
      src/web.js

+ 14 - 14
src/robot.js

@@ -555,20 +555,20 @@ function delRobot(app) {
 
 // 新策略-获取状态
 function predictorState(port) {
-    logger.info('#####################predictorState:');
-    var accUrl = "http://127.0.0.1:" + port
-    var config = getRustConfig()
-
-    // curl -X GET -H "auth: 4L" -H "token: r7T\$8gBV\!f&L@E2+" "http://127.0.0.1:111/predictor_state"
-    execSync(`curl -X GET -H "auth: ${config.headers.auth}" -H "token: ${config.headers.token}" "http://127.0.0.1:${port}/predictor_state"`, (error, stdout, stderr) => {
-        if (error) {
-            logger.info(`#####################汇报:获取状态请求失败: ${error.message}`)
-            return {'code': -1, 'data': null, "message": `获取状态请求失败`}
-        }
-
-        logger.info('#####################-d', stdout);
-        return {'code': 200, 'data': stdout, "message": "SUCCESS"}
-    });
+    // logger.info('#####################predictorState:');
+    // var accUrl = "http://127.0.0.1:" + port
+    // var config = getRustConfig()
+    //
+    // // curl -X GET -H "auth: 4L" -H "token: r7T\$8gBV\!f&L@E2+" "http://127.0.0.1:111/predictor_state"
+    // execSync(`curl -X GET -H "auth: ${config.headers.auth}" -H "token: ${config.headers.token}" "http://127.0.0.1:${port}/predictor_state"`, (error, stdout, stderr) => {
+    //     if (error) {
+    //         logger.info(`#####################汇报:获取状态请求失败: ${error.message}`)
+    //         return {'code': -1, 'data': null, "message": `获取状态请求失败`}
+    //     }
+    //
+    //     logger.info('#####################-d', stdout);
+    //     return {'code': 200, 'data': stdout, "message": "SUCCESS"}
+    // });
 
     // //拿到策略余额
     // try {

+ 14 - 3
src/web.js

@@ -145,9 +145,20 @@ function init() {
         })
 
         if (port !== -1) {
-            let data = robot.predictorState(port)
-            logger.info('#####################-ok');
-            res.send(data);
+            logger.info('#####################predictorState:');
+            var accUrl = "http://127.0.0.1:" + port
+            var config = getRustConfig()
+
+            execSync(`curl -X GET -H "auth: ${config.headers.auth}" -H "token: ${config.headers.token}" "http://127.0.0.1:${port}/predictor_state"`, (error, stdout, stderr) => {
+                if (error) {
+                    logger.info(`#####################汇报:获取状态请求失败: ${error.message}`)
+                    res.send({'code': -1, 'data': null, "message": `获取状态请求失败`});
+                }
+
+                logger.info('#####################-d', stdout);
+                logger.info('#####################-ok');
+                res.send({'code': 200, 'data': stdout, "message": "SUCCESS"});
+            });
         } else {
             res.send({'code': -1, 'data': null, "message": "机器人不存在"});
         }