Добавлена периодическая проверка изменений inpx
для автоматического пересоздания поисковой БД
This commit is contained in:
@@ -22,6 +22,7 @@ module.exports = {
|
|||||||
maxFilesDirSize: 1024*1024*1024,//1Gb
|
maxFilesDirSize: 1024*1024*1024,//1Gb
|
||||||
queryCacheEnabled: true,
|
queryCacheEnabled: true,
|
||||||
cacheCleanInterval: 60,//minutes
|
cacheCleanInterval: 60,//minutes
|
||||||
|
inpxCheckInterval: 60,//minutes
|
||||||
lowMemoryMode: false,
|
lowMemoryMode: false,
|
||||||
|
|
||||||
webConfigParams: ['name', 'version', 'branch', 'bookReadLink'],
|
webConfigParams: ['name', 'version', 'branch', 'bookReadLink'],
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const propsToSave = [
|
|||||||
'maxFilesDirSize',
|
'maxFilesDirSize',
|
||||||
'queryCacheEnabled',
|
'queryCacheEnabled',
|
||||||
'cacheCleanInterval',
|
'cacheCleanInterval',
|
||||||
|
'inpxCheckInterval',
|
||||||
'lowMemoryMode',
|
'lowMemoryMode',
|
||||||
'server',
|
'server',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ class WebWorker {
|
|||||||
maxSize: this.config.maxFilesDirSize,
|
maxSize: this.config.maxFilesDirSize,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
this.periodicCleanDir(dirConfig);//no await
|
this.periodicCleanDir(dirConfig);//no await
|
||||||
|
this.periodicCheckInpx();//no await
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
@@ -489,6 +491,35 @@ class WebWorker {
|
|||||||
ayncExit.exit(1);
|
ayncExit.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async periodicCheckInpx() {
|
||||||
|
const inpxCheckInterval = this.config.inpxCheckInterval;
|
||||||
|
if (!inpxCheckInterval)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (1) {// eslint-disable-line no-constant-condition
|
||||||
|
try {
|
||||||
|
while (this.myState != ssNormal)
|
||||||
|
await utils.sleep(1000);
|
||||||
|
|
||||||
|
log('check inpx file for changes');
|
||||||
|
const newInpxHash = await utils.getFileHash(this.config.inpxFile, 'sha256', 'hex');
|
||||||
|
|
||||||
|
const dbConfig = await this.dbConfig();
|
||||||
|
const currentInpxHash = (dbConfig.inpxHash ? dbConfig.inpxHash : '');
|
||||||
|
|
||||||
|
if (newInpxHash !== currentInpxHash) {
|
||||||
|
log('inpx file changed, recreating DB');
|
||||||
|
await this.recreateDb();
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
log(LM_ERR, `periodicCheckInpx: ${e.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
//await utils.sleep(inpxCheckInterval*60*1000);
|
||||||
|
await utils.sleep(10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = WebWorker;
|
module.exports = WebWorker;
|
||||||
Reference in New Issue
Block a user