Browse Source

Улучшение BUCServer

Book Pauk 11 months ago
parent
commit
d634ebf14c
2 changed files with 9 additions and 1 deletions
  1. 3 0
      server/config/base.js
  2. 6 1
      server/core/BookUpdateChecker/BUCServer.js

+ 3 - 0
server/config/base.js

@@ -56,6 +56,9 @@ module.exports = {
             ip: '0.0.0.0',
             port: '33443',
             accessToken: '',
+            shciForHost: {
+                'samlib.ru': 300000
+            },
         }*/
     ],
 

+ 6 - 1
server/core/BookUpdateChecker/BUCServer.js

@@ -51,6 +51,7 @@ class BUCServer {
             
             this.checkQueue = [];
             this.hostChecking = {};
+            this.shciForHost = this.config.shciForHost || {};//sameHostCheckInterval for host
 
             this.main(); //no await
 
@@ -316,7 +317,11 @@ class BUCServer {
                         log(LM_ERR, `error ${row.id} > ${e.stack ? e.stack : e.message}`);
                     } finally {
                         (async() => {
-                            await utils.sleep(this.sameHostCheckInterval);
+                            const sameHostCheckInterval = this.shciForHost[url.hostname] || this.sameHostCheckInterval;
+
+                            log(`delay ${sameHostCheckInterval}ms for host '${url.hostname}'`);
+                            await utils.sleep(sameHostCheckInterval);
+                            
                             this.hostChecking[url.hostname] = false;
                         })();
                     }