|
@@ -148,18 +148,30 @@ function init() {
|
|
|
logger.info('#####################predictorState:');
|
|
|
var config = getRustConfig()
|
|
|
|
|
|
- var com = `curl -X GET -H 'auth: 4L' -H 'token: r7T$8gBV!f&L@E2+' "http://127.0.0.1:${port}/predictor_state"`;
|
|
|
- logger.info('#####################com:', com);
|
|
|
- execSync(com, (error, stdout, stderr) => {
|
|
|
- if (error) {
|
|
|
+ // var com = `curl -X GET -H 'auth: 4L' -H 'token: r7T$8gBV!f&L@E2+' "http://127.0.0.1:${port}/predictor_state"`;
|
|
|
+ // logger.info('#####################com:', com);
|
|
|
+ // execSync(com, (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"});
|
|
|
+ // });
|
|
|
+
|
|
|
+ http.request_get(`http://127.0.0.1:${port}/predictor_state`, {...config.headers})
|
|
|
+ .then((data) => {
|
|
|
+ logger.info('#####################-d', data);
|
|
|
+ return {'code': 200, 'data': data, "message": "SUCCESS"}
|
|
|
+ })
|
|
|
+ // 处理可能发生的错误
|
|
|
+ .catch((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"});
|
|
|
- });
|
|
|
+ // logger.error(`#####################汇报:获取状态请求失败: ${error.message}`)
|
|
|
+ return {'code': -1, 'data': null, "message": `获取状态请求失败${error.message}`}
|
|
|
+ });
|
|
|
} else {
|
|
|
res.send({'code': -1, 'data': null, "message": "机器人不存在"});
|
|
|
}
|