sa-cronus
v1.0.0
Published
monitoring tool
Downloads
16
Maintainers
Readme
cronus
Schedules custom monitoring jobs and serves a socket.io connected monitoring website.
Demo
Installation standalone
$ npm i -g sa-cronus;
Start server
$ sa-cronus [--port 3000] --folder ./jobs [--logFolder d:\logs];
Installation module
$ npm i sa-cronus;
Usage programmatically
#!/usr/bin/env node
const minimist = require('minimist')
const CronusServer = require('sa-cronus')
const argv = minimist(process.argv.slice(2))
const port = argv.port || 3000
const cronusServer = new CronusServer({
port,
folders: [argv.folder],
bunyanLogSettings: {
name: 'cronus',
streams: [
{
level: 'trace',
stream: process.stdout
}
]
}
})
const run = async () => {
await cronusServer.start()
}
run()
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
Changelog
V1.0.0
- Migrate to Twitter Bootstrap 5
Breaking changes
job.testAsync
is obsolete useasync job.verify
insteadjob.shouldTimeout
bool
is obsolete usejob.timeout
int
insteadjob.timout
is now optional but recommended
Example promise monitor job
var Job = function () {
this.cronPattern = "*/2 * * * * *";
this.name = "async";
this.iconCssClassName = "fa fa-calendar-times-o";
this.timeout = 100000
this.description = "You will see this message every 2 seconds";
return this;
};
Job.prototype.verify = async function (controller) {
controller.log.warn("invoke async test function")
return true;
};
module.exports = Job;
More example jobs can be found at /jobs/.