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

// const pkg = require('../package.json');
const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test3';

const domains = {

  // api: 'http://api.yoho.cn/',
  // service: 'http://service.yoho.cn/',
  // ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/',

  // liveApi: 'http://testapi.live.yohops.com:9999/',
  // singleApi: 'http://api-test3.yohops.com:9999/',

  // gray
  // api: 'http://apigray.yoho.cn/',
  // service: 'http://apigray.yoho.cn/',

  // platformApi: 'http://172.16.6.210:8088/',

  api: 'http://api-test3.dev.yohocorp.com/',
  service: 'http://api-test3.dev.yohocorp.com/',
  ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/',
};

module.exports = {
  app: 'h5',
  appVersion: '6.6.0', // 调用api的版本
  appName: 'yohoapp-node',
  port: 6003,
  siteUrl: '//m.yohobuy.com',
  assetUrl: '//m.yohobuy.com:5001/yohoapp-node/',
  testCode: 'yoho4946abcdef#$%&!@',
  domains,
  yohoVerifyUdid: 'ca5c462a-e28b-407d-8061-5e204398e3cc',
  signExtend: {
    business_line: 'yohobuy'
  },
  report: {
    host: 'badjs.yoho.cn',
    port: 80,
    db: 'web-apm',
    immediate: true
  },
  subDomains: {
    host: '.m.yohobuy.com',
    default: '//m.yohobuy.com',
    guang: '//guang.m.yohobuy.com',
    list: '//list.m.yohobuy.com',
    search: '//search.m.yohobuy.com',
    huodong: '//huodong.m.yohobuy.com',
    activity: '//activity.yohobuy.com',
    index: '//m.yohobuy.com'
  },
  useCache: false,
  loggers: {
    infoFile: {
      close: true,
      name: 'info',
      level: 'info',
      filename: 'logs/info.log',
      maxFiles: 1,
      tailable: true,
      maxsize: Math.pow(1024, 3),
      timestamp() {
        return new Date().toString();
      }
    },
    errorFile: {
      close: true,
      name: 'error',
      level: 'error',
      filename: 'logs/error.log',
      maxFiles: 1,
      tailable: true,
      maxsize: Math.pow(1024, 3),
      handleExceptions: true,
      timestamp() {
        return new Date().toString();
      }
    },
    console: {
      level: 'debug',
      colorize: 'all',
      prettyPrint: true,
      debugStdout: true
    }
  },
  zookeeperServer: '127.0.0.1:2181',
  jsSdk: '//cdn.yoho.cn/js-sdk/1.3.10/jssdk.js',
  redis: {
    connect: {
      host: '192.168.102.49',

      // host: '127.0.0.1',
      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.0.1',
      port: '6379',
      pass: '',
      prefix: 'yohobuy_session:'
    }
  },
  qiniu: {
    ACCESS_KEY: 'BwWhoJN536BnV3CzlE20AjNKC9O2bP0l5tFpKsDU',
    SECRET_KEY: '_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK',
    BUCKET_NAME: 'cmsimg01'
  },
  qiniuYohoCdn: {
    ACCESS_KEY: 'BwWhoJN536BnV3CzlE20AjNKC9O2bP0l5tFpKsDU',
    SECRET_KEY: '_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK',
    ORIGIN: 'https://cdn.yoho.cn',
    BUCKET_NAME: 'yohocdn'
  }
};

if (isProduction) {
  Object.assign(module.exports, {
    domains: {
      api: 'http://api.yoho.yohoops.org/',
      ufo: 'http://ufoapi.yohoops.org/',
      service: 'http://api.yoho.yohoops.org/',
    },
    useCache: true,
    zookeeperServer: 'web.zookeeper.yohoops.org:2181',
    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: 'yohobuy_session:'
      }
    },
    report: {
      host: 'badjs.yohoops.org',
      port: 80,
      db: 'web-apm',
      immediate: true
    },
    monitorReport: {
      host: '10.66.4.25',
      port: 8086,
      db: 'web_monitor',
    },
    loggers: {
      infoFile: {
        name: 'info',
        level: 'info',
        filename: '/Data/logs/yoho-community-web/info/info.log',
        maxFiles: 1,
        tailable: true,
        maxsize: Math.pow(1024, 3),
        zippedArchive: true,
        timestamp() {
          return new Date().toString();
        }
      },
      errorFile: {
        name: 'error',
        level: 'error',
        filename: '/Data/logs/yoho-community-web/error/error.log',
        maxFiles: 1,
        tailable: true,
        maxsize: Math.pow(1024, 3),
        zippedArchive: true,
        handleExceptions: true,
        timestamp() {
          return new Date().toString();
        }
      },
      console: {
        close: true,
        level: 'info',
        colorize: 'all',
        prettyPrint: true,
        debugStdout: true
      }
    }
  });
} else if (isTest) {
  Object.assign(module.exports, {
    assetUrl: '//cdn.yoho.cn/yohobuywap-node/',
    domains: {
      api: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/',
      ufo: process.env.UFO_API || 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/',
      service: process.env.TEST_API || 'http://api-test3.dev.yohocorp.com/'
    },
    useCache: true,
    monitorReport: {
      host: '192.168.102.22',
      port: 8086,
      db: 'web_monitor',
    },
    zookeeperServer: 'zk01-yohoops-org:2181',
    loggers: {
      infoFile: {
        name: 'info',
        level: 'debug',
        filename: '/Data/logs/yoho-community-web/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/yoho-community-web/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
      }
    }
  });
}