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