-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
32 lines (28 loc) · 887 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
const config = require('./src/config')();
const run = require('./src/run');
const evaluateMetrics = require('./src/evaluateMetrics');
const fs = require('fs');
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
process.on('exit', function() {
console.log('Stopping worker');
});
process.on('SIGINT', function() {
console.log('SIGINT, Stopping worker');
process.exit(1);
});
config.__version = packageJson.version
async function main() {
console.log(`✅ Running lastmile v${packageJson.version}`)
const firstRun = run(config);
if (config.probeOneShot) {
const metrics = await firstRun;
const {status, exitCode} = evaluateMetrics(metrics);
console.log(`Probes finished with status = ${status} (${exitCode})`);
process.exit(exitCode);
} else {
setInterval(() => {
run(config);
}, config.probeInterval);
}
}
main();