|
|
|
@ -11,6 +11,7 @@ const Pins = require("../pins");
|
|
|
|
|
const Core = require("../commands/core");
|
|
|
|
|
const Saferphore = require("saferphore");
|
|
|
|
|
const Logger = require("../log");
|
|
|
|
|
const Tasks = require("../storage/tasks");
|
|
|
|
|
|
|
|
|
|
const Env = {
|
|
|
|
|
Log: {},
|
|
|
|
@ -31,6 +32,7 @@ var ready = false;
|
|
|
|
|
var store;
|
|
|
|
|
var pinStore;
|
|
|
|
|
var blobStore;
|
|
|
|
|
var tasks;
|
|
|
|
|
const init = function (config, _cb) {
|
|
|
|
|
const cb = Util.once(Util.mkAsync(_cb));
|
|
|
|
|
if (!config) {
|
|
|
|
@ -66,6 +68,18 @@ const init = function (config, _cb) {
|
|
|
|
|
}
|
|
|
|
|
blobStore = blob;
|
|
|
|
|
}));
|
|
|
|
|
}).nThen(function (w) {
|
|
|
|
|
Tasks.create({
|
|
|
|
|
log: Env.Log,
|
|
|
|
|
taskPath: config.taskPath,
|
|
|
|
|
store: store,
|
|
|
|
|
}, w(function (err, tasks) {
|
|
|
|
|
if (err) {
|
|
|
|
|
w.abort();
|
|
|
|
|
return void cb(err);
|
|
|
|
|
}
|
|
|
|
|
Env.tasks = tasks;
|
|
|
|
|
}));
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
cb();
|
|
|
|
|
});
|
|
|
|
@ -393,6 +407,10 @@ const removeOwnedBlob = function (data, cb) {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const runTasks = function (data, cb) {
|
|
|
|
|
Env.tasks.runAll(cb);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const COMMANDS = {
|
|
|
|
|
COMPUTE_INDEX: computeIndex,
|
|
|
|
|
COMPUTE_METADATA: computeMetadata,
|
|
|
|
@ -404,6 +422,7 @@ const COMMANDS = {
|
|
|
|
|
GET_MULTIPLE_FILE_SIZE: getMultipleFileSize,
|
|
|
|
|
GET_HASH_OFFSET: getHashOffset,
|
|
|
|
|
REMOVE_OWNED_BLOB: removeOwnedBlob,
|
|
|
|
|
RUN_TASKS: runTasks,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
process.on('message', function (data) {
|
|
|
|
@ -439,7 +458,7 @@ process.on('message', function (data) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
process.on('uncaughtException', function (err) {
|
|
|
|
|
console.error('[%s] UNCAUGHT EXCEPTION IN DB WORKER');
|
|
|
|
|
console.error('[%s] UNCAUGHT EXCEPTION IN DB WORKER', new Date());
|
|
|
|
|
console.error(err);
|
|
|
|
|
console.error("TERMINATING");
|
|
|
|
|
process.exit(1);
|
|
|
|
|