|
|
|
@ -81,7 +81,8 @@ Workers.initialize = function (Env, config, _cb) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var drained = true;
|
|
|
|
|
var sendCommand = function (msg, _cb) {
|
|
|
|
|
var sendCommand = function (msg, _cb, opt) {
|
|
|
|
|
opt = opt || {};
|
|
|
|
|
var index = getAvailableWorkerIndex();
|
|
|
|
|
|
|
|
|
|
var state = workers[index];
|
|
|
|
@ -119,7 +120,9 @@ Workers.initialize = function (Env, config, _cb) {
|
|
|
|
|
delete state.tasks[txid];
|
|
|
|
|
})));
|
|
|
|
|
|
|
|
|
|
response.expect(txid, cb, 180000);
|
|
|
|
|
// default to timing out affter 180s if no explicit timeout is passed
|
|
|
|
|
var timeout = typeof(opt.timeout) !== 'undefined'? opt.timeout: 180000;
|
|
|
|
|
response.expect(txid, cb, timeout);
|
|
|
|
|
state.worker.send(msg);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -354,13 +357,17 @@ Workers.initialize = function (Env, config, _cb) {
|
|
|
|
|
Env.evictInactive = function (cb) {
|
|
|
|
|
sendCommand({
|
|
|
|
|
command: 'EVICT_INACTIVE',
|
|
|
|
|
}, cb);
|
|
|
|
|
}, cb, {
|
|
|
|
|
timeout: 1000 * 60 * 300, // time out after 300 minutes (5 hours)
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Env.runTasks = function (cb) {
|
|
|
|
|
sendCommand({
|
|
|
|
|
command: 'RUN_TASKS',
|
|
|
|
|
}, cb);
|
|
|
|
|
}, cb, {
|
|
|
|
|
timeout: 1000 * 60 * 10, // time out after 10 minutes
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Env.writeTask = function (time, command, args, cb) {
|
|
|
|
|