-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
46 lines (37 loc) · 1.15 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
38
39
40
41
42
43
require('dotenv').config();
const { getDB, pruneDB } = require("./db");
const { startApi } = require("./api");
const { bootstrapTiny } = require("./firehose");
const DB = getDB(); //initalize databases
const historyProvider = process.env.HISTORY_PROVIDER || 'firehose';
async function main(){
await startApi();
const startBlock = await bootstrapTiny();
await pruneDB();
if (historyProvider === 'firehose'){
const { streamFirehose } = require('./firehose');
await streamFirehose(startBlock);
}
else if (historyProvider === 'ship'){
const SHIP = require('./ship');
const ship = new SHIP();
ship.start(process.env.SHIP_WS);
}
else if (historyProvider === 'nodeos'){
const { startNodeos } = require('./nodeos');
startNodeos();
}
console.log("READY")
}
// var signals = { SIGHUP: 1, SIGINT: 2, SIGTERM: 15 };
// Object.keys(signals).forEach((signal) => {
// process.on(signal, () => {
// console.log(`process received a ${signal} signal`);
// let value = signals[signal];
// process.exit();
// // process.exit(128 + value);
// });
// });
main().then().catch(ex=>{
console.log("Main error",ex);
});