-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (30 loc) · 1.02 KB
/
index.js
File metadata and controls
37 lines (30 loc) · 1.02 KB
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 jobs = require('./models/jobs');
const { jobScheduler } = require('./interpreter/jobInterpreter');
const { evaluateJob } = require('./evaluation/evaluateJob')
const { evaluateColdstart } = require('./evaluation/coldstart')
const { connectDb } = require('./db');
const cache = require('micro-cacheable')
const { router, get } = require('microrouter')
require('dnscache')({
"enable": true,
"ttl": 300,
"cachesize": 1000
})
const main = async () => {
await connectDb();
jobs.forEach(jobScheduler)
}
main();
const threeDaysAgo = Date.now() - 1000 * 60 * 60 * 24 * 3;
const server = async (req, res) => {
const obj = {
'job-overhead-01': await evaluateJob(jobs.find(x => x.id === 'job-overhead-01'), threeDaysAgo),
'job-coldstart-01': await evaluateColdstart(jobs.find(x => x.id === 'job-coldstart-01'))
}
return obj;
}
const cached = cache(60 * 60 * 1000, server);
const health = async (req, res) => {
return 'alive';
}
module.exports = router(get('/health', health), get('/', cached));