forked from covidatlas/li
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start
executable file
·54 lines (48 loc) · 1.21 KB
/
start
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /usr/bin/env node
const arc = require('@architect/functions')
const timeseriesRegenerator = require('./src/scheduled/regen-timeseries/index.js').handler
const taskRunner = require('./src/scheduled/runner/index.js').handler
const args = require('./src/cli/args.js')
const checkSandbox = require('./src/cli/check-sandbox.js')
const makeNice = require('./src/cli/make-nice.js')
let { date } = args
let { crawl, scrape, regenerate, regenTimeseries, runner } = makeNice(args)
;(async () => {
checkSandbox()
process.env.NODE_ENV = 'testing'
if (crawl) {
await arc.events.publish({
name: 'crawler',
payload: {
source: crawl
}
})
}
if (scrape) {
await arc.events.publish({
name: 'scraper',
payload: {
date,
source: scrape
}
})
}
if (regenerate) {
console.log(`⚠️ About to regenerate ${regenerate}, you've got 3 seconds to cancel!`)
setTimeout(async () => {
await arc.events.publish({
name: 'regenerator',
payload: {
date,
source: regenerate
}
})
}, 3000)
}
if (regenTimeseries) {
await timeseriesRegenerator()
}
if (runner) {
await taskRunner()
}
})()