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


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

module.exports = {
    app: 'web',
    appVersion: '5.8.0', // 调用api的版本
    port: 6002,
    siteUrl: 'http://www.yohobuy.com',
    cookieDomain: '.yohobuy.com',
    domains: {
        // test3
        // singleApi: 'http://api-test3.yohops.com:9999/',
        // api: 'http://api-test3.yohops.com:9999/',
        // service: 'http://service-test3.yohops.com:9999/',
        // serviceNotify: 'http://service-test3.yohops.com:9999/',
        // global: 'http://global-test-soa.yohops.com:9999/',
        // platformApi: 'http://192.168.102.48:8088/',

        // test2
        // singleApi: 'http://api-test2.yohops.com:9999/',
        // api: 'http://api-test2.yohops.com:9999/',
        // service: 'http://service-test2.yohops.com:9999/',
        // serviceNotify: 'http://service-test2.yohops.com:9999/',
        // global: 'http://global-test-soa.yohops.com:9999/',
        // platformApi: 'http://192.168.102.48:8088/',

        // prod
        // singleApi: 'http://single.yoho.cn/',
        // api: 'http://api.yoho.cn/',
        // service: 'http://service.yoho.cn/',
        // serviceNotify: 'http://service.yoho.cn/',
        // global: 'http://api-global.yohobuy.com/',
        // platformApi: 'http://172.16.6.210:8088/',

        // gray
        // singleApi: 'http://single.gray.yohops.com/',
        // api: 'http://api.gray.yohops.com/',
        // service: 'http://service.gray.yohops.com/',
        // platformApi: 'http://172.16.6.210:8088/',

        // dev
        api: 'http://dev-api.yohops.com:9999/',
        service: 'http://dev-service.yohops.com:9999/',
        serviceNotify: 'http://dev-service.yohops.com:9999/',
        singleApi: 'http://dev-api.yohops.com:9999/',
        platformApi: 'http://192.168.102.48:8088/',

        imSocket: 'ws://socket.yohobuy.com:10240',
        imCs: 'http://im.yohobuy.com/api',
        unionApi: 'http://172.16.6.90:8080/'
    },
    subDomains: {
        host: '.yohobuy.com',
        default: '//www.yohobuy.com',
        guang: '//guang.yohobuy.com',
        list: '//list.yohobuy.com',
        search: '//search.yohobuy.com',
        huodong: '//huodong.yohobuy.com',
        activity: '//activity.yohobuy.com',
        index: '//yohobuy.com'
    },
    useOneapm: false,
    useCache: false,
    memcache: {
        master: ['127.0.0.1:11211'],
        slave: ['127.0.0.1:11211'],
        session: ['127.0.0.1:11211'],
        timeout: 1000,
        retries: 0
    },
    interfaceShunt: {
        open: false
    },
    loggers: {
        infoFile: {
            close: true,
            name: 'info',
            level: 'info',
            filename: 'logs/info.log',
            maxFiles: 7
        },
        errorFile: {
            name: 'error',
            level: 'error',
            filename: 'logs/error.log',
            handleExceptions: true,
            maxFiles: 7
        },
        udp: { // send by udp
            measurement: 'yohobuy_node_log',
            level: 'debug', // logger level
            host: 'influxdblog.web.yohoops.org', // influxdb host
            port: '4444' // influxdb port
        },
        console: {
            level: 'info',
            colorize: 'all',
            prettyPrint: true
        }
    },
    thirdLogin: {
        wechat: {
            appID: 'wx3ae21dcbb82ad672',
            appSecret: 'e78afb2321e6a19085767e1a0f0d52c1'
        },
        sina: {
            appID: '3739328910',
            appSecret: '9d44cded26d048e23089e5e975c93df1'
        },
        qq: {
            appID: '100229394',
            appSecret: 'c0af9c29e0900813028c2ccb42021792'
        },
        alipay: {
            appID: '2088701661478015',
            appSecret: 'kcxawi9bb07mzh0aq2wcirsf9znusobw'
        },
        douban: {
            appID: '03b4e36bf13dc75a0b1eaa43d3b9560e',
            appSecret: 'f16d5913e8610672'
        },
        renren: {
            appID: '783130c654c94a77ace97054ae266019',
            appSecret: '05e430de8c1e40d3a1f39ca8d3f8252c'
        }
    },
    gee_captcha: {
        id: '356b333091cdb78cd788e7bdd5f05c9f',
        key: '6fef8ee77e41429de68455eeb052ce37'
    },
    UNIVERSAL_CAPTCHA: 'yoho4946abcdef#$%&!@',
    apiCache: {
        cache: false
    },
    zookeeperServer: '192.168.102.168:2188',
    maxQps: 1200,
    maxQps10m: 2500,
    sessionMemcachedPrefix: 'yohobuy_session:',
    redis: {
        connect: {
            host: '127.0.0.1',
            port: '6379',
            retry_strategy(options) {
                if (options.error && options.error.code === 'ECONNREFUSED') {
                    console.log('redis连接不成功');
                }
                if (options.total_retry_time > 1000 * 60 * 60 * 6) {
                    console.log('redis连接超时');
                    return;
                }
                if (options.attempt > 10) {
                    return 1000 * 60 * 60 * 0.5;
                }
                return Math.min(options.attempt * 100, 1000);
            }
        }
    }
};

if (isProduction) {
    Object.assign(module.exports, {
        appName: 'www.yohobuy.com',
        domains: {
            singleApi: 'http://single.yoho.cn/',
            api: 'http://api.yoho.yohoops.org/',
            service: 'http://service.yoho.yohoops.org/',
            search: 'http://search.yohoops.org/yohosearch/',
            global: 'http://api-global.yohobuy.com/',
            serviceNotify: 'http://service.yoho.cn/',
            imSocket: 'wss://imsocket.yohobuy.com:443',
            imCs: 'https://imhttp.yohobuy.com/api',
            platformApi: 'http://api.platform.yohoops.org',
            unionApi: 'http://union.yoho.cn/'
        },
        memcache: {
            master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
            slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'],
            session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
            poolSize: 100,
            reconnect: 5000,
            timeout: 300,
            retries: 0,
            retry: 3000
        },
        useOneapm: true,
        useCache: true,
        interfaceShunt: {
            open: false,
            url: 'http://123.206.2.55/strategy'
        },
        zookeeperServer: 'web.zookeeper.yohoops.org:2181',
        redis: {
            connect: {
                host: 'web.redis.yohoops.org'
            },
            port: '6379',
            retry_strategy(options) {
                if (options.error && options.error.code === 'ECONNREFUSED') {
                    console.log('redis连接不成功');
                }
                if (options.total_retry_time > 1000 * 60 * 60 * 6) {
                    console.log('redis连接超时');
                    return;
                }
                if (options.attempt > 10) {
                    return 1000 * 60 * 60 * 0.5;
                }
                return Math.min(options.attempt * 100, 1000);
            }
        }
    });
} else if (isTest) {
    Object.assign(module.exports, {
        appName: 'www.yohobuy.com for test',
        domains: {
            singleApi: process.env.TEST_API || 'http://192.168.102.31:8092/brower',
            api: process.env.TEST_API || 'http://testapi.yoho.cn:28078/',
            service: process.env.TEST_SERVICE || 'http://testservice.yoho.cn:28077/',
            global: process.env.TEST_GOLBAL || 'http://global-test-soa.yohops.com:9999/',
            search: process.env.TEST_SEARCH || 'http://192.168.102.216:8080/yohosearch/',
            serviceNotify: process.env.TEST_SERVICE || 'http://testservice.yoho.cn:28077/',
            imSocket: 'ws://socket.yohobuy.com:10240',
            imCs: 'http://im.yohobuy.com/api'
        },
        useOneapm: true,
        useCache: true,
        memcache: {
            master: ['127.0.0.1:12111'],
            slave: ['127.0.0.1:12112'],
            session: ['127.0.0.1:12111'],
            timeout: 1000,
            retries: 0
        }
    });
}