-
Notifications
You must be signed in to change notification settings - Fork 18
/
run.js
33 lines (25 loc) · 874 Bytes
/
run.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
var configPath = (process.argv[2] || './config.json');
var events = require('events'),
Monitor = require('./monitor/monitor'),
config = require(configPath);
// create global event system
var emitter = new events.EventEmitter();
// always log errors, just in case
emitter.on('error', function(err) {
var timeStamp = (new Date()).toString();
console.log(timeStamp, ' Error:');
console.log(err);
console.log('-----');
if (config.exitOnError) {
process.exit(1);
}
});
// initialize outputs
var outputs = [];
for (var i = 0; i < config['outputs'].length; ++i) {
var outputConfig = config['outputs'][i];
var Output = require(outputConfig['file']);
outputs.push(new Output(emitter, outputConfig['config']));
}
// start monitor
var monitor = new Monitor(config['feeds'], config['throttling'], config['dbconfig'], emitter);