-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathindex.js
107 lines (48 loc) · 2.31 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import SegfaultHandler from 'segfault-handler'
SegfaultHandler.registerHandler('crash.log');
//var INFURA_ROPSTEN_URL = 'https://ropsten.infura.io/v3/';
//var INFURA_MAINNET_URL = 'https://mainnet.infura.io/v3/';
var https_enabled = process.argv[2] === 'https';
var pool_env = 'production';
if( process.argv[2] == "staging" )
{
pool_env = 'staging'
}
import FileUtils from './lib/util/file-utils.js'
import cron from 'node-cron'
let poolConfigFull = FileUtils.readJsonFileSync('/pool.config.json');
let poolConfig = poolConfigFull[pool_env]
console.log('poolConfig',poolConfig, poolConfigFull)
console.log('init');
import MongoInterface from './lib/mongo-interface.js'
import PeerInterface from './lib/peer-interface.js';
import TokenInterface from './lib/token-interface.js';
import Web3ApiHelper from './lib/util/web3-api-helper.js';
import PoolStatsHelper from './lib/util/pool-stats-helper.js'
import WebServer from './lib/web-server.js'
import DiagnosticsManager from './lib/diagnostics-manager.js'
import ContractHelper from './lib/util/contract-helper.js'
import TokenDataHelper from './lib/util/token-data-helper.js'
var accountConfig;
import Web3 from 'web3'
init( );
async function init( )
{
// Code to run if we're in the master process
let mongoInterface = new MongoInterface()
let diagnosticsManager = new DiagnosticsManager()
let webServer = new WebServer()
await mongoInterface.init( 'tokenpool_'.concat(pool_env))
await diagnosticsManager.init(poolConfig, mongoInterface)
await webServer.init(https_enabled,poolConfig,mongoInterface)
diagnosticsManager.update()
let web3apihelper = new Web3ApiHelper(mongoInterface, poolConfig)
let tokenInterface = new TokenInterface(mongoInterface, poolConfig)
// await peerInterface.init(web3,accountConfig,mongoInterface,tokenInterface,pool_env) //initJSONRPCServer();
//This worker is dying !!!
tokenInterface.update();
web3apihelper.update() //fetch API data
let peerInterface = new PeerInterface(mongoInterface, poolConfig)
peerInterface.update();
peerInterface.listenForJSONRPC();
}