Небольшие исправления, queue теперь в одном экземпляре на класс
This commit is contained in:
@@ -7,6 +7,8 @@ const LimitedQueue = require('../../LimitedQueue');
|
|||||||
const textUtils = require('./textUtils');
|
const textUtils = require('./textUtils');
|
||||||
const utils = require('../../utils');
|
const utils = require('../../utils');
|
||||||
|
|
||||||
|
const queue = new LimitedQueue(2, 20, 3*60*1000);//3 минуты ожидание подвижек
|
||||||
|
|
||||||
class ConvertBase {
|
class ConvertBase {
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@@ -14,7 +16,6 @@ class ConvertBase {
|
|||||||
this.calibrePath = `${config.dataDir}/calibre/ebook-convert`;
|
this.calibrePath = `${config.dataDir}/calibre/ebook-convert`;
|
||||||
this.sofficePath = '/usr/bin/soffice';
|
this.sofficePath = '/usr/bin/soffice';
|
||||||
this.pdfToHtmlPath = '/usr/bin/pdftohtml';
|
this.pdfToHtmlPath = '/usr/bin/pdftohtml';
|
||||||
this.queue = new LimitedQueue(2, 20, 3*60*1000);//3 минуты ожидание подвижек
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(data, opts) {// eslint-disable-line no-unused-vars
|
async run(data, opts) {// eslint-disable-line no-unused-vars
|
||||||
@@ -35,7 +36,7 @@ class ConvertBase {
|
|||||||
async execConverter(path, args, onData, abort) {
|
async execConverter(path, args, onData, abort) {
|
||||||
let q = null;
|
let q = null;
|
||||||
try {
|
try {
|
||||||
q = await this.queue.get(() => {onData();});
|
q = await queue.get(() => {onData();});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('Слишком большая очередь конвертирования. Пожалуйста, попробуйте позже.');
|
throw new Error('Слишком большая очередь конвертирования. Пожалуйста, попробуйте позже.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +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, 5*60*1000);//5 минут ожидание подвижек
|
||||||
|
|
||||||
let instance = null;
|
let instance = null;
|
||||||
|
|
||||||
@@ -27,7 +28,6 @@ class ReaderWorker {
|
|||||||
this.config.tempPublicDir = `${config.publicDir}/tmp`;
|
this.config.tempPublicDir = `${config.publicDir}/tmp`;
|
||||||
fs.ensureDirSync(this.config.tempPublicDir);
|
fs.ensureDirSync(this.config.tempPublicDir);
|
||||||
|
|
||||||
this.queue = new LimitedQueue(5, 100, 5*60*1000);//5 минут ожидание подвижек
|
|
||||||
this.workerState = new WorkerState();
|
this.workerState = new WorkerState();
|
||||||
this.down = new FileDownloader(config.maxUploadFileSize);
|
this.down = new FileDownloader(config.maxUploadFileSize);
|
||||||
this.decomp = new FileDecompressor(2*config.maxUploadFileSize);
|
this.decomp = new FileDecompressor(2*config.maxUploadFileSize);
|
||||||
@@ -64,7 +64,7 @@ class ReaderWorker {
|
|||||||
wState.set({state: 'queue', step: 1, totalSteps: 1});
|
wState.set({state: 'queue', step: 1, totalSteps: 1});
|
||||||
try {
|
try {
|
||||||
let qSize = 0;
|
let qSize = 0;
|
||||||
q = await this.queue.get((place) => {
|
q = await queue.get((place) => {
|
||||||
wState.set({place, progress: (qSize ? Math.round((qSize - place)/qSize*100) : 0)});
|
wState.set({place, progress: (qSize ? Math.round((qSize - place)/qSize*100) : 0)});
|
||||||
if (!qSize)
|
if (!qSize)
|
||||||
qSize = place;
|
qSize = place;
|
||||||
|
|||||||
Reference in New Issue
Block a user