mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-10 23:45:07 +00:00
scheduler is plugin now
This commit is contained in:
parent
3f84e7c94e
commit
4332c50bfc
2
app.js
2
app.js
@ -236,8 +236,6 @@ Steppy(
|
||||
|
||||
require('./projectsWatcher').init(app, this.slot());
|
||||
|
||||
require('./scheduler').init(app, this.slot());
|
||||
|
||||
// init resources
|
||||
require('./resources')(app);
|
||||
},
|
||||
|
@ -2,6 +2,7 @@
|
||||
# plugins:
|
||||
# - nci-mail-notification
|
||||
# - nci-jabber-notification
|
||||
# - nci-scheduler
|
||||
|
||||
nodes:
|
||||
- type: local
|
||||
|
@ -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",
|
||||
|
44
scheduler.js
44
scheduler.js
@ -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();
|
||||
};
|
Loading…
Reference in New Issue
Block a user