npm install sa-cronus





``bash`
$ npm i -g sa-cronus;
bash
$ sa-cronus [--port 3000] --folder ./jobs [--logFolder d:\logs];
`Installation module
`bash
$ npm i sa-cronus;
`Usage programmatically
`javascript
#!/usr/bin/env nodeconst 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
$3
- Migrate to Twitter Bootstrap 5
#### Breaking changes
-
job.testAsync is obsolete use async job.verify instead
- job.shouldTimeout bool is obsolete use job.timeout int instead
- job.timout is now optional but recommendedExample promise monitor job
`javascriptvar 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/.