common.js 9.65 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';

// 修改 sockets 默认设置
require('http').globalAgent.maxSockets = 10;

module.exports = {
    app: 'web',
    appName: 'yohobuy-node',
    appVersion: '6.3.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://api-test3.yohops.com:9999/',
        serviceNotify: 'http://api-test3.yohops.com:9999/',
        global: 'http://global-test-soa.yohops.com:9999/',
        platformApi: 'http://192.168.102.48:8088/',
        yohoNowApi: 'http://yohonow-test.yohops.com:9999/',

        // test2
        // singleApi: 'http://api-test2.yohops.com:9999/',
        // api: 'http://api-test2.yohops.com:9999/',
        // service: 'http://api-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://api.yoho.cn/',
        // api: 'http://api.yoho.cn/',
        // service: 'http://api.yoho.cn/',
        // serviceNotify: 'http://service.yoho.cn/',
        // platformApi: 'http://172.16.6.210:8088/',

        // gray
        // singleApi: 'http://apigray.yoho.cn/',
        // api: 'http://apigray.yoho.cn/',
        // service: 'http://apigray.yoho.cn/',
        // platformApi: 'http://172.16.6.210:8088/',

        // dev
        // api: 'http://dev-api.yohops.com:9999/',
        // service: 'http://dev-api.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'
    },
    report: {
        host: 'localhost',
        port: 6009,
        db: 'web-apm'
    },
    useOneapm: false,
    useCache: true,
    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: 14
        },
        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: 'debug',
            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: '93c70db61fe276f93ce781ad17dc47cd',
    apiCache: {
        cache: true
    },
    zookeeperServer: '192.168.102.168:2188',
    sessionMemcachedPrefix: 'yohobuy_session:',
    redis: {
        connect: {
            host: '192.168.102.49',
            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);
            }
        }
    },
    REQUEST_LIMIT: {
        // 10s 最多访问5次
        10: 10,

        // 30s 最多访问15次
        30: 20,

        // 60s 最多访问15次
        60: 30,

        // 100s 最多访问15次
        600: 100
    }
};

if (isProduction) {
    Object.assign(module.exports, {
        appName: 'yohobuy-node',
        domains: {
            singleApi: 'http://api.yoho.yohoops.org/',
            api: 'http://api.yoho.yohoops.org/',
            service: 'http://api.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/',
            yohoNowApi: 'http://new.yohoboys.com/',
        },
        memcache: {
            master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111',
                'memcache3.yohoops.org:12111', 'memcache4.yohoops.org:12111'],
            slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112',
                'memcache3.yohoops.org:12112', 'memcache4.yohoops.org:12112'],
            session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111',
                'memcache3.yohoops.org:12111', 'memcache4.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);
            }
        },
        report: {
            host: 'badjs.yoho.cn',
            port: 80,
            db: 'web-apm'
        }
    });
} else if (isTest) {
    Object.assign(module.exports, {
        appName: 'yohobuy-node',
        domains: {
            singleApi: process.env.TEST_API || 'http://testapi.yoho.cn:28078/',
            api: process.env.TEST_API || 'http://testapi.yoho.cn:28078/',
            service: process.env.TEST_API || 'http://testapi.yoho.cn:28078/',
            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_API || 'http://testapi.yoho.cn:28078/',
            imSocket: 'ws://socket.yohobuy.com:10240',
            imCs: 'http://im.yohobuy.com/api',
            yohoNowApi: process.env.YOHO_NOW_API || 'http://yohonow-test.yohops.com:9999/',
        },
        useOneapm: true,
        useCache: true,
        memcache: {
            master: ['127.0.0.1:12111', '127.0.0.1:12111', '127.0.0.1:12111'],
            slave: ['127.0.0.1:12112', '127.0.0.1:12112', '127.0.0.1:12112'],
            session: ['120.0.0.1:12111', '127.0.0.1:12111', '127.0.0.1:12111'],
            timeout: 1000,
            retries: 0
        },
        redis: {
            connect: {
                host: '192.168.104.32',
                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);
                }
            }
        }
    });
}