Небольшой тюнинг BUCServer
This commit is contained in:
@@ -27,8 +27,8 @@ class BUCServer {
|
||||
|
||||
this.cleanQueryInterval = 300*dayMs;//интервал очистки устаревших
|
||||
this.oldQueryInterval = 14*dayMs;//интервал устаревания запроса на обновление
|
||||
this.checkingInterval = 5*hourMs;//интервал проверки обновления одного и того же файла
|
||||
this.sameHostCheckInterval = 1000;//интервал проверки файла на том же сайте, не менее
|
||||
this.checkingInterval = 1*dayMs;//интервал проверки обновления одного и того же файла
|
||||
this.sameHostCheckInterval = 10*1000;//интервал проверки файла на том же сайте, не менее
|
||||
} else {
|
||||
this.maxCheckQueueLength = 10;//максимальная длина checkQueue
|
||||
this.fillCheckQueuePeriod = 10*1000;//период пополнения очереди
|
||||
@@ -262,7 +262,7 @@ class BUCServer {
|
||||
let unchanged = true;
|
||||
let hash = '';
|
||||
|
||||
const headers = await this.down.head(row.id);
|
||||
const headers = await this.down.head(row.id, {timeout: 10*1000});
|
||||
|
||||
const etag = headers['etag'] || '';
|
||||
const modTime = headers['last-modified'] || '';
|
||||
@@ -276,7 +276,7 @@ class BUCServer {
|
||||
&& (!size || !row.size || (size !== row.size))
|
||||
) {
|
||||
|
||||
const downdata = await this.down.load(row.id);
|
||||
const downdata = await this.down.load(row.id, {timeout: 10*1000});
|
||||
|
||||
size = downdata.length;
|
||||
hash = await utils.getBufHash(downdata, 'sha256', 'hex');
|
||||
@@ -327,7 +327,7 @@ class BUCServer {
|
||||
log(LM_ERR, e.stack);
|
||||
}
|
||||
|
||||
await utils.sleep(10);
|
||||
await utils.sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ const https = require('https');
|
||||
const axios = require('axios');
|
||||
const utils = require('./utils');
|
||||
|
||||
const userAgent = 'Mozilla/5.0 (X11; HasCodingOs 1.0; Linux x64) AppleWebKit/637.36 (KHTML, like Gecko) Chrome/70.0.3112.101 Safari/637.36 HasBrowser/5.0';
|
||||
const userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0';
|
||||
|
||||
class FileDownloader {
|
||||
constructor(limitDownloadSize = 0) {
|
||||
@@ -16,7 +16,6 @@ class FileDownloader {
|
||||
headers: {
|
||||
'accept-encoding': 'gzip, compress, deflate',
|
||||
'user-agent': userAgent,
|
||||
timeout: 300*1000,
|
||||
},
|
||||
httpsAgent: new https.Agent({
|
||||
rejectUnauthorized: false // решение проблемы 'unable to verify the first certificate' для некоторых сайтов с валидным сертификатом
|
||||
@@ -26,6 +25,9 @@ class FileDownloader {
|
||||
if (opts)
|
||||
options = Object.assign({}, opts, options);
|
||||
|
||||
if (!options.timeout)
|
||||
options.timeout = 300*1000;//5 min
|
||||
|
||||
try {
|
||||
const res = await axios.get(url, options);
|
||||
|
||||
@@ -77,8 +79,8 @@ class FileDownloader {
|
||||
const options = {
|
||||
headers: {
|
||||
'user-agent': userAgent,
|
||||
timeout: 10*1000,
|
||||
},
|
||||
timeout: 10*1000,
|
||||
};
|
||||
|
||||
const res = await axios.head(url, options);
|
||||
|
||||
Reference in New Issue
Block a user