integrate task execution into the server directly

This commit is contained in:
ansuz 2019-04-23 13:28:05 +02:00
parent 7b55df5931
commit 7665720d77
1 changed files with 17 additions and 6 deletions

View File

@ -254,17 +254,28 @@ var nt = nThen(function (w) {
Logger.create(config, w(function (_log) { Logger.create(config, w(function (_log) {
log = config.log = _log; log = config.log = _log;
})); }));
}).nThen(function (w) {
var Tasks = require("./storage/tasks");
//log.debug('loading task scheduler');
Tasks.create(config, w(function (e, tasks) {
config.tasks = tasks;
}));
}).nThen(function (w) { }).nThen(function (w) {
if (config.useExternalWebsocket) { return; } if (config.useExternalWebsocket) { return; }
Storage.create(config, w(function (_store) { Storage.create(config, w(function (_store) {
config.store = _store; config.store = _store;
})); }));
}).nThen(function (w) {
if (!config.enableTaskScheduling) { return; }
var Tasks = require("./storage/tasks");
Tasks.create(config, w(function (e, tasks) {
if (e) {
throw e;
}
config.tasks = tasks;
setInterval(function () {
tasks.runAll(function (err) {
if (err) {
// either TASK_CONCURRENCY or an error with tasks.list
// in either case it is already logged.
}
});
}, 1000 * 60 * 5); // run every five minutes
}));
}).nThen(function (w) { }).nThen(function (w) {
config.rpc = typeof(config.rpc) === 'undefined'? './rpc.js' : config.rpc; config.rpc = typeof(config.rpc) === 'undefined'? './rpc.js' : config.rpc;
if (typeof(config.rpc) !== 'string') { return; } if (typeof(config.rpc) !== 'string') { return; }