Added possibility to enable / disable tasks.

This commit is contained in:
baldo 2016-06-05 12:18:37 +02:00
parent 8f8d78d1df
commit 53a0ecd366
7 changed files with 109 additions and 46 deletions

View file

@ -35,20 +35,24 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger, confi
schedule: expr,
job: job,
runningSince: false,
lastRunStarted: false
lastRunStarted: false,
state: 'idle',
enabled: true
};
task.run = function () {
if (task.runningSince) {
if (task.runningSince || !task.enabled) {
// job is still running, skip execution
return;
}
task.runningSince = moment();
task.lastRunStarted = task.runningSince;
task.state = 'running';
job.run(function () {
task.runningSince = false;
task.state = 'idle';
});
};
@ -65,7 +69,6 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger, confi
schedule('0 */1 * * * *', 'MailQueueJob');
if (config.client.monitoring.enabled) {
schedule('* * * * * *', 'TestJob');
schedule('30 */15 * * * *', 'NodeInformationRetrievalJob');
schedule('45 */5 * * * *', 'MonitoringMailsSendingJob');
schedule('0 0 3 * * *', 'NodeInformationCleanupJob'); // every night at 3:00

View file

@ -1,18 +0,0 @@
'use strict';
angular.module('ffffng').factory('TestJob', function (Logger) {
var i = 1;
return {
run: function (callback) {
var j = i;
i += 1;
Logger.tag('test').info('Start test job... ' + j);
setTimeout(function () {
Logger.tag('test').info('Done test job... ' + j);
callback();
}, 2000);
}
};
});