mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
Add workers for notes to leverage CPU intensive work loading
This commit is contained in:
parent
793aef0e2e
commit
4ccfdfa538
3 changed files with 191 additions and 90 deletions
19
lib/workers/noteRevisionSaver.js
Normal file
19
lib/workers/noteRevisionSaver.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
// core
|
||||
var logger = require("../logger.js");
|
||||
var models = require("../models");
|
||||
|
||||
process.on('message', function (data) {
|
||||
if (!data || !data.msg || data.msg !== 'save note revision') return process.exit();
|
||||
models.Revision.saveAllNotesRevision(function (err, notes) {
|
||||
if (err) {
|
||||
logger.error('note revision saver failed: ' + err);
|
||||
return process.exit();
|
||||
}
|
||||
if (notes && notes.length <= 0) {
|
||||
process.send({
|
||||
msg: 'empty'
|
||||
});
|
||||
}
|
||||
process.exit();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue