sa-cronus

1.0.0 • Public • Published

cronus

logo
Schedules custom monitoring jobs and serves a socket.io connected monitoring website.

NPM Version Build Status NPM Downloads Massachusetts Institute of Technology (MIT) Donate

Demo

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 use async job.verify instead
  • job.shouldTimeout bool is obsolete use job.timeout int instead
  • job.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/.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    1
    • latest

Version History

Package Sidebar

Install

npm i sa-cronus

Weekly Downloads

9

Version

1.0.0

License

MIT

Unpacked Size

2.46 MB

Total Files

22

Last publish

Collaborators

  • s-a