-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (33 loc) · 1.31 KB
/
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
35
36
37
const schedule = require('node-schedule');
const AppInsightsClientConfiguration = require('applicationinsights').Configuration;
const RigMetricsBo = require('./business/Rig/RigMetricsBo');
const NiceHashMetricsBo = require('./business/NiceHash/NiceHashMetricsBo');
const AppInsightsClient = require('./MetricClient/AppInsightsClient');
const Worker = require('./Worker');
const appInsightsCfg = require('./config/appInsightsCfg');
const rigCfg = require('./config/rigCfg');
const nicehashCfg = require('./config/nicehashCfg');
const appCfg = require('./config/appConfig');
const appInsightsClient = new AppInsightsClient(appInsightsCfg);
AppInsightsClientConfiguration.setInternalLogging(true, true);
const rigs = rigCfg.map(rig => new RigMetricsBo({
rigName: rig.name,
host: rig.host,
xmrstakPort: rig.xmrstakPort,
openhwPort: rig.openhwPort,
metricClients: [
appInsightsClient
]
}));
const nicehashes = nicehashCfg.map(nh => new NiceHashMetricsBo({
address: nh.address,
metricClients: [
appInsightsClient
]
}));
const worker = new Worker({rigs, nicehashes});
const job = schedule.scheduleJob(appCfg.scheduleString, worker.work.bind(worker));
process.on('SIGINT', () => {
job.cancel();
console.log('Job cancelled. Exit gracefully');
});