-
Notifications
You must be signed in to change notification settings - Fork 31
/
app.js
42 lines (34 loc) · 1.1 KB
/
app.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
var program = require('commander');
var log = require('./lib/log');
var server = require('./lib/server');
var configPath = './config.json';
// Define program options
program
.version('2.1.6')
.option('-c, --config <path>', 'set config path. default to ./config.json')
.parse(process.argv);
configPath = program.config || configPath;
// Load config
log.info('1/2 Loading config file ' + configPath);
var config = require(configPath);
// Validate config
var missingKeys = [
'contract', 'contract_name',
'jsonrpc_host', 'jsonrpc_port',
'exchange_interface', 'exchange_port',
'owner'].filter(function (key) {
return config[key] === undefined;
});
if (missingKeys.length) {
log.error('Following required keys are not defined in config: ' + missingKeys.join(', '));
process.exit(1);
}
// Start server
try {
log.info('2/2 Setting up ' + config.exchange_interface + ' interface on port ' + config.exchange_port);
server.listen(config);
} catch(err) {
log.error('Error while settup up jsonrpc server: ' + err.message);
process.exit(1);
};
log.info('Server Ready!');