Merge branch 'release/0.9.10-4'
This commit is contained in:
@@ -42,21 +42,32 @@ class ConvertBase {
|
|||||||
throw new Error('Слишком большая очередь конвертирования. Пожалуйста, попробуйте позже.');
|
throw new Error('Слишком большая очередь конвертирования. Пожалуйста, попробуйте позже.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abort = (abort ? abort : () => false);
|
||||||
|
const myAbort = () => {
|
||||||
|
return q.abort() || abort();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (myAbort())
|
||||||
|
throw new Error('abort');
|
||||||
|
|
||||||
const result = await utils.spawnProcess(path, {
|
const result = await utils.spawnProcess(path, {
|
||||||
killAfter: 3600,//1 час
|
killAfter: 3600,//1 час
|
||||||
args,
|
args,
|
||||||
onData: (data) => {
|
onData: (data) => {
|
||||||
q.resetTimeout();
|
if (queue.freed > 0)
|
||||||
|
q.resetTimeout();
|
||||||
onData(data);
|
onData(data);
|
||||||
},
|
},
|
||||||
//будем периодически проверять работу конвертера и если очереди нет, то разрешаем работу пинком onData
|
//будем периодически проверять работу конвертера и если очереди нет, то разрешаем работу пинком onData
|
||||||
onUsage: (stats) => {
|
onUsage: (stats) => {
|
||||||
if (queue.freed > 1 && stats.cpu >= 10)
|
if (queue.freed > 0 && stats.cpu >= 10) {
|
||||||
|
q.resetTimeout();
|
||||||
onData('.');
|
onData('.');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onUsageInterval: 10,
|
onUsageInterval: 10,
|
||||||
abort
|
abort: myAbort
|
||||||
});
|
});
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
const error = `${result.code}|FORLOG|, exec: ${path}, args: ${args.join(' ')}, stdout: ${result.stdout}, stderr: ${result.stderr}`;
|
const error = `${result.code}|FORLOG|, exec: ${path}, args: ${args.join(' ')}, stdout: ${result.stdout}, stderr: ${result.stderr}`;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const utils = require('../utils');
|
|||||||
const log = new (require('../AppLogger'))().log;//singleton
|
const log = new (require('../AppLogger'))().log;//singleton
|
||||||
|
|
||||||
const cleanDirPeriod = 60*60*1000;//1 раз в час
|
const cleanDirPeriod = 60*60*1000;//1 раз в час
|
||||||
const queue = new LimitedQueue(5, 100, 4*60*1000);//4 минуты ожидание подвижек
|
const queue = new LimitedQueue(5, 100, 2*60*1000 + 15000);//2 минуты ожидание подвижек
|
||||||
|
|
||||||
let instance = null;
|
let instance = null;
|
||||||
|
|
||||||
@@ -130,7 +130,8 @@ class ReaderWorker {
|
|||||||
convertFilename = `${this.config.tempDownloadDir}/${tempFilename2}`;
|
convertFilename = `${this.config.tempDownloadDir}/${tempFilename2}`;
|
||||||
await this.bookConverter.convertToFb2(decompFiles, convertFilename, opts, progress => {
|
await this.bookConverter.convertToFb2(decompFiles, convertFilename, opts, progress => {
|
||||||
wState.set({progress});
|
wState.set({progress});
|
||||||
q.resetTimeout();
|
if (queue.freed > 0)
|
||||||
|
q.resetTimeout();
|
||||||
}, q.abort);
|
}, q.abort);
|
||||||
|
|
||||||
//сжимаем файл в tmp, если там уже нет с тем же именем-sha256
|
//сжимаем файл в tmp, если там уже нет с тем же именем-sha256
|
||||||
|
|||||||
Reference in New Issue
Block a user