-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.js
92 lines (77 loc) · 1.94 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// [clean env]
const fs = require("fs");
["", "\-shm", "\-wal"].forEach(function(k) {
if (fs.exists("./fibos_chain.db" + k)) fs.unlink("./fibos_chain.db" + k);
});
let setLogs = (logPath) => {
if (!fs.exists(logPath)) fs.mkdir(logPath);
console.add([{
type: "console",
levels: [console.FATAL, console.ALERT, console.CRIT, console.ERROR, console.WARN, console.NOTICE, console.INFO],
}, {
type: "file",
levels: [console.FATAL, console.ALERT, console.CRIT, console.ERROR],
path: logPath + "error.log",
split: "hour",
count: 128
}, {
type: "file",
levels: [console.WARN],
path: logPath + "warn.log",
split: "hour",
count: 128
}, {
type: "file",
levels: [console.INFO, console.NOTICE],
path: logPath + "access.log",
split: "hour",
count: 128
}]);
}
setLogs("./logs/");
// [fibos]
const fibos = require("fibos");
fibos.config_dir = "./data";
fibos.data_dir = "./data";
fibos.load("http", {
"http-server-address": "0.0.0.0:8870",
"access-control-allow-origin": "*",
"http-validate-host": false,
"verbose-http-errors": true
});
fibos.load("net", {
"p2p-peer-address": ["127.0.0.1:9801"],
"p2p-listen-endpoint": "0.0.0.0:9870"
});
fibos.load("producer");
fibos.load("chain", {
"contracts-console": true,
"delete-all-blocks": true,
"genesis-json": "genesis.json"
});
fibos.load("chain_api");
//[fibos-tracker]
const Tracker = require("../");
// Tracker.Config.replay = true;
// Tracker.Config.replayStatrBn = 0;
Tracker.Config.DBconnString = "mysql://root:[email protected]/fibos_chain";
const tracker = new Tracker();
tracker.use(require("./addons/eosio_token_transfers.js"));
tracker.emitter();
fibos.start();
// [http server]
const http = require("http");
let httpServer = new http.Server("", 8080, [
(req) => {
req.session = {};
}, {
'^/ping': (req) => {
req.response.write("pong");
},
'/1.0/app': tracker.app,
"*": [function(req) {}]
},
function(req) {}
]);
httpServer.crossDomain = true;
httpServer.asyncRun();