README
cronus
Schedules custom monitoring jobs and serves a socket.io connected monitoring website.
Demo
Installation
$ npm i -g sa-cronus;
Develop and test monitoring script modules
$ node server/test.js --script jobs/1-minute.js;
Start server
$ sa-cronus [--port 3000] --folder ./jobs [--logFolder d:\logs];
Cron patterns
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, optional)
Detailed description : https://github.com/ncb000gt/node-cron
Example sync monitor job
"use strict";
var Job = function() {
this.cronPattern = "* * * * * *";
this.name = "unicorn ONE";
this.description = "You will see this message every second";
this.iconCssClassName = "fa fa-database";
return this;
};
Job.prototype.test = function(/*controller*/) {
return false;
};
module.exports = Job;
Example async monitor job
"use strict";
var Job = function() {
this.cronPattern = "*/20 * * * * *";
this.name = "unicorn timeout";
this.description = "20-seconds rotating timeout";
this.iconCssClassName = "fa fa-calendar-times-o";
this.shouldTimeout = false;
return this;
};
Job.prototype.testAsync = function(controller, done) {
var time = 2000;
if (this.shouldTimeout){
time = 6000;
}
this.shouldTimeout = !this.shouldTimeout;
setTimeout(function () {
done(true);
}, time);
//return true;
};
module.exports = Job;
More example jobs can be found at /jobs/.