blob: 2671a26d18a1c283432bdcd7b4cd22d4d0db1e58 [file] [log] [blame]
Matteo Scandoloe3ed0162016-12-01 10:09:12 -08001(function () {
2 'use strict';
3
4 // NOTE do we still need CLI args?
5 // Won't be better to use NODE_ENV and the native node-yaml-config feature
6
7 const argv = require('yargs').argv;
8 const path = require('path');
9 const yaml_config = require('node-yaml-config');
10 const logger = require('../config/logger.js');
11
12 // if a config file is specified in as a CLI arguments use that one
13 const cfgFile = argv.config || 'config.yml';
14
15 let config;
16 try {
17 logger.log('debug', `Loading ${cfgFile}`);
18 config = yaml_config.load(path.join(__dirname, cfgFile));
19 }
20 catch(e) {
21 logger.log('debug', `No ${cfgFile} found, using default params`);
22 }
23
24 module.exports = {
25 xos: {
26 host: (config && config.xos) ? config.xos.host : 'xos',
27 port: (config && config.xos) ? config.xos.port : 9999
28 },
29 redis: {
30 host: (config && config.redis) ? config.redis.host : 'redis',
31 port: (config && config.redis) ? config.redis.port : 6379
32 },
33 gateway: {
34 port: (config && config.gateway) ? config.gateway.port : 3000
35 }
36 };
37})();