scheduler is plugin now

This commit is contained in:
oleg 2016-01-08 22:12:01 +03:00
parent 3f84e7c94e
commit 4332c50bfc
4 changed files with 1 additions and 47 deletions

2
app.js
View File

@ -236,8 +236,6 @@ Steppy(
require('./projectsWatcher').init(app, this.slot());
require('./scheduler').init(app, this.slot());
// init resources
require('./resources')(app);
},

View File

@ -2,6 +2,7 @@
# plugins:
# - nci-mail-notification
# - nci-jabber-notification
# - nci-scheduler
nodes:
- type: local

View File

@ -47,7 +47,6 @@
"dependencies": {
"chokidar": "1.0.3",
"colors": "1.1.2",
"cron": "1.0.9",
"data.io": "0.3.0",
"nlevel": "1.0.3",
"node-static": "0.7.6",

View File

@ -1,44 +0,0 @@
'use strict';
var _ = require('underscore'),
CronJob = require('cron').CronJob;
exports.init = function(app, callback) {
var logger = app.lib.logger('scheduler'),
projectJobs = {};
app.projects.on('projectLoaded', function(project) {
var time = project.buildEvery && project.buildEvery.time;
if (time) {
logger.log(
'Start job for loaded project "%s" by schedule "%s"',
project.name,
time
);
projectJobs[project.name] = {};
projectJobs[project.name].job = new CronJob({
cronTime: time,
onTick: function() {
logger.log('Run project "%s"', project.name);
app.builds.create({
projectName: project.name,
withScmChangesOnly: project.buildEvery.withScmChangesOnly,
initiator: {type: 'scheduler'}
});
},
start: true
});
}
});
app.projects.on('projectUnloaded', function(project) {
if (project.name in projectJobs) {
logger.log('Stop job for unloaded project "%s"', project.name);
projectJobs[project.name].job.stop();
delete projectJobs[project.name];
}
});
callback();
};