-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (26 loc) · 873 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node --no-warnings
const config = require("./config");
const Check = require("./check");
const schedule = require('node-schedule');
var program = require('commander');
program
.version('0.1.0')
.option('-d, --debug', 'Display debug')
.parse(process.argv);
const debug = program.debug;
const notifiers = {};
for (let name in config.notifiers) {
const notifierConfig = config.notifiers[name];
const TypeClass = require('./notifications/' + notifierConfig.type);
notifiers[name] = new TypeClass(notifierConfig);
}
const checks = config.checks;
checks.map(checkConfiguration => {
const check = new Check(checkConfiguration, notifiers, debug);
schedule.scheduleJob(check.getRule(), async () => {
if (debug) {
console.log("Check ", check.getName());
}
await check.execute();
});
});