forked from mountain-pass/addressr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.js
executable file
·38 lines (36 loc) · 903 Bytes
/
loader.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
38
import debug from 'debug'
import { esConnect } from './client/elasticsearch'
import { loadGnaf } from './service/address-service'
import { printVersion } from './service/printVersion'
const logger = debug('api')
const error = debug('error')
if (process.env.DEBUG == undefined) {
debug.enable('api,error')
}
const start = process.hrtime()
esConnect()
.then(() => {
logger('es client connected')
})
.then(() => {
console.log('======================')
console.log('Addressr - Data Loader')
console.log('======================')
printVersion()
})
.then(loadGnaf)
.then(() => {
logger('data loaded')
})
.then(() => {
const end = process.hrtime(start)
logger(`Execution time: ${end[0]}s ${end[1] / 1000000}ms`)
})
.then(() => {
logger(`Fin`)
process.exit()
})
.catch(error_ => {
error('error loading data', error_)
throw error_
})