Browse Source

上报地址修改!

hl 10 months ago
parent
commit
4d331d17c1
4 changed files with 11 additions and 8 deletions
  1. 1 1
      src/Interval.js
  2. 4 4
      src/robot.js
  3. 2 2
      src/utils/node.json
  4. 4 1
      src/web.js

+ 1 - 1
src/Interval.js

@@ -40,7 +40,7 @@ function reportDel() {
 
 // 5秒扫描本机所有机器人状态,进行上报
 function reportStatus() {
-    const intervalInMilliseconds = 5000;
+    const intervalInMilliseconds = 3000;
     setInterval(() => {
         robot.appMap.forEach((value, key) => {
             // logger.info('当前',robot.appMap);

+ 4 - 4
src/robot.js

@@ -118,7 +118,7 @@ async function run(param) {
             var dowHeaders = {...config.headers};
             if (platform === 'win32') {
                 downloadFileWithPowerShell(
-                    config.dowbaseUrl + config.dowAppURL + '/?path=' + appName,
+                    config.baseUrl + config.dowAppURL + '/?path=' + appName,
                     appPath + "/" + appName,
                     dowHeaders, (err, b) => {
                         if (err === null) {
@@ -132,7 +132,7 @@ async function run(param) {
                     });
             } else {
                 downloadFileWithLinux(
-                    config.dowbaseUrl + config.dowAppURL + '/?path=' + appName,
+                    config.baseUrl + config.dowAppURL + '/?path=' + appName,
                     appPath + "/" + appName,
                     dowHeaders, (err, b) => {
                         if (err === null) {
@@ -410,7 +410,7 @@ function downloadFileWithLinux(url, destination, headers, funBreak) {
 function robotStatus(app) {
     var config = getRustConfig()
     var msg = (app.threadStatus !== RobotStatus.ERROR ? "完成" : app.errorMessage)
-    http.request_post(`${config.baseUrl}/report/statusReport`, {
+    http.request_post(`${config.reportedUrl}/report/statusReport`, {
         "robotId": app.id,
         "status": app.threadStatus,
         "msg": msg
@@ -434,7 +434,7 @@ function robotAmount(app) {
                 //余额有变动上报一次
                 // logger.info(`余额当前:${(app.nowBalance + "")}--${(d.now_balance + "")}--`);
                 if ((app.nowBalance + "") !== (d.now_balance + "")) {
-                    http.request_post(`${config.baseUrl}/report/amountReport`, {
+                    http.request_post(`${config.reportedUrl}/report/amountReport`, {
                         "robotId": app.id,
                         "amount": d.now_balance
                     }, {...config.headers})

+ 2 - 2
src/utils/node.json

@@ -1,7 +1,7 @@
 {
   "rustConfig": {
-    "baseUrl": "http://57.180.248.115:7000",
-    "dowbaseUrl": "https://4lapi.skyfffire.com/api",
+    "baseUrl": "https://4lapi.skyfffire.com/api",
+    "reportedUrl": "http://57.180.248.115/api",
     "dowAppURL": "/report/downloadFile",
     "dowConfigURL": "/report/getRobotConfig",
     "filePath":"./rust",

+ 4 - 1
src/web.js

@@ -43,6 +43,9 @@ function init() {
     app.get('/', (req, res) => {
         res.send('is OK!');
     });
+    app.get('/robotList', (req, res) => {
+        res.send({'code': 200, 'data': robot.getAppMap(), "message": "SUCCESS"});
+    });
     app.get('/app11', (req, res) => {
         // res.send('is OK!');
         var s = JSON.parse("{}");
@@ -118,7 +121,7 @@ function init() {
 // node-已上线-上报
 function robotNodeStatus() {
     var config = getRustConfig()
-    http.request_post(`${config.baseUrl}/report/beOnline`, {}, {...config.headers}).then((data) => {
+    http.request_post(`${config.reportedUrl}/report/beOnline`, {}, {...config.headers}).then((data) => {
         // logger.info('??', data);
         logger.info('#####################汇报:node 在线-上报成功!', data);
     }).catch((error) => {