common.js 5.31 KB
/**
 * 系统配置
 *
 * @author hbomb qiqi.zhou@yoho.cn
 * @date 2016/05/06
 */


const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test3';

module.exports = {
  app: 'h5',
  appVersion: '5.6.0', // 调用api的版本
  port: 6004,
  siteUrl: '//m.yohoblk.com',
  signExtend: {
    app_type: 1,
    business_line: 'yohoblk'
  },
  domains: {
    api: 'http://api-test3.dev.yohocorp.com/',
    service: 'http://api-test3.dev.yohocorp.com/',
    singleApi: 'http://api-test3.dev.yohocorp.com/'

        // api: 'http://dev-api.yohops.com:9999/',
        // service: 'http://dev-service.yohops.com:9999/',
        // singleApi: 'http://192.168.102.27:8092/'
        // //
        // api: 'http://api.yoho.cn/',
        // service: 'http://service.yoho.cn/',
        // singleApi: 'http://single.yoho.cn/'
  },
  subDomains: {
    host: '.m.yohoblk.com',
    default: '//m.yohoblk.com',
    index: '//m.yohoblk.com'
  },
  report: {
    host: '10.66.0.139',
    port: 8086,
    db: 'web-apm'
  },
  useOneapm: false,
  useCache: true,
  redis: {
    connect: {
      host: '127.0.0.1',

            // host: '192.168.102.49',
      port: '6379',
      enable_offline_queue: false,
      retry_strategy(options) {
        if (options.error && options.error.code === 'ECONNREFUSED') {
          console.log('connect redis server fail');
        }

        if (options.attempt < 10) {
          return Math.min(options.attempt * 100, 1000);
        } else if (options.attempt > 10 && options.attempt < 100) {
          return 1000;
        } else {
          return 1000 * 10;
        }
      }
    },
    session: {
      host: '127.0.01',
      port: '6379',
      prefix: 'yohoblk_session:'
    }
  },
  interfaceShunt: {
    useInterfaceShunt: false,
    tencentServers: {
      api: ['123.206.1.98', '123.206.2.80'],
      service: ['123.206.1.98', '123.206.2.80']
    },
    awsServers: {
      api: 'app-java-168863769.cn-north-1.elb.amazonaws.com.cn',
      service: 'service-yoho-579825100.cn-north-1.elb.amazonaws.com.cn'
    }
  },
  loggers: {
    infoFile: {
      name: 'info',
      level: 'info',
      filename: '/Data/logs/yohoblk-wap/info/info.log',
      maxFiles: 1,
      tailable: true,
      maxsize: Math.pow(1024, 3),
    },
    errorFile: {
      name: 'error',
      level: 'error',
      filename: '/Data/logs/yohoblk-wap/error/error.log',
      handleExceptions: true,
      maxFiles: 1,
      tailable: true,
      maxsize: Math.pow(1024, 3),
    },
    console: {
      level: 'debug',
      prettyPrint: true,
      debugStdout: true
    }
  },
  thirdLogin: {
    wechat: {
      appID: 'wx75e5a7c0c88e45c2',
      appSecret: 'ce21ae4a3f93852279175a167e54509b'
    }
  }
};

if (isProduction) {
  Object.assign(module.exports, {
    appName: 'm.yohoblk.com',
    domains: {
      api: 'http://api.yoho.yohoops.org/',
      service: 'http://api.yoho.yohoops.org/',
      singleApi: 'http://api.yoho.yohoops.org/',
    },
    redis: {
      connect: {
        host: 'redis.web.yohoops.org',
        port: '6379',
        password: 'redis9646',
        enable_offline_queue: false,
        retry_strategy(options) {
          if (options.error && options.error.code === 'ECONNREFUSED') {
            console.log('connect redis server fail');
          }

          if (options.attempt < 10) {
            return Math.min(options.attempt * 100, 1000);
          } else if (options.attempt > 10 && options.attempt < 100) {
            return 1000;
          } else {
            return 1000 * 10;
          }
        }
      },
      session: {
        host: 'redis.web.yohoops.org',
        port: '6379',
        pass: 'redis9646',
        prefix: 'yohoblk_session:'
      }
    },
    useOneapm: true,
    useCache: true,
    interfaceShunt: {
      useInterfaceShunt: false,
      tencentServers: {
        api: ['123.206.1.98', '123.206.2.80'],
        service: ['123.206.1.98', '123.206.2.80']
      },
      awsServers: {
        api: 'app-java-168863769.cn-north-1.elb.amazonaws.com.cn',
        service: 'service-yoho-579825100.cn-north-1.elb.amazonaws.com.cn'
      }
    },
    loggers: {
      infoFile: {
        name: 'info',
        level: 'info',
        filename: '/Data/logs/yohoblk-wap/info/info.log',
        maxFiles: 1,
        tailable: true,
        maxsize: Math.pow(1024, 3),
        timestamp() {
          return new Date().toString();
        }
      },
      errorFile: {
        name: 'error',
        level: 'error',
        filename: '/Data/logs/yohoblk-wap/error/error.log',
        maxFiles: 1,
        tailable: true,
        maxsize: Math.pow(1024, 3),
        handleExceptions: true,
        timestamp() {
          return new Date().toString();
        }
      },
      console: {
        close: true,
        level: 'info',
        colorize: 'all',
        prettyPrint: true,
        debugStdout: true
      }
    },
    report: {
      host: 'influxdblog.web.yohoops.org',
      port: 8086,
      db: 'web-apm'
    }
  });
} else if (isTest) {
  Object.assign(module.exports, {
    appName: 'm.yohoblk.com for test',
    domains: {
      api: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/',
      service: process.env.TEST_SERVICE || 'http://api-test3.dev.yohocorp.com/',
      singleApi: process.env.TEST_SINGLE || 'http://api-test3.dev.yohocorp.com/'
    },
    useOneapm: true,
    useCache: true
  });
}