Matteo Scandolo | e3ed016 | 2016-12-01 10:09:12 -0800 | [diff] [blame] | 1 | (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', |
Matteo Scandolo | 141e286 | 2017-01-10 12:03:40 -0800 | [diff] [blame] | 27 | port: (config && config.xos) ? config.xos.port : 8000 |
Matteo Scandolo | e3ed016 | 2016-12-01 10:09:12 -0800 | [diff] [blame] | 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 | })(); |