-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
61 lines (53 loc) · 1.59 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const log4js = require("log4js");
const yargs = require("yargs");
const { Server } = require("./src/Server")
const argv = yargs
.option("configName", {
alias: "c",
description: "Which config to use, ex: harmony-mainnet",
type: "string"
})
.option("firstBlock", {
alias: "f",
description: "Begin processing at block number",
type: "integer"
})
.option("untilBlock", {
alias: "u",
description: "Process blocks until block number (but not including)",
type: "integer"
})
.option("debug", {
alias: "d",
description: "Print debug information about transactions",
type: "boolean"
})
.demandOption(["configName"], "Please provide config name")
.help()
.alias("help", "h")
.argv
const configName = argv.configName
const logFile = `logs/${configName}.log`
const configFile = `./${configName}-config.json`
const stateFile = `state/${configName}-state.json`
const config = require(configFile)
log4js.configure({
appenders: {
out: { type: 'stdout' },
default: {
type: "dateFile",
filename: logFile,
pattern: 'yyyy-MM-dd',
numBackups: config.numLogBackups || 30,
compress: true,
}
},
categories: {default: {appenders: ["out","default"], level: "info"}}
});
const path = require("path");
config.stateFilenameAbsPath = path.resolve(stateFile)
config.firstBlock = argv.firstBlock
config.untilBlock = argv.untilBlock
config.debug = argv.debug || false
const server = new Server(config)
server.start()