config.js 9.21 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';
const path = require('path');

module.exports = {
    app: 'web',
    appVersion: '5.6.1', // 调用api的版本
    port: 6005,
    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/'

        // 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/',

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

        // 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/',

        // imSocket: 'ws://socket.yohobuy.com:10240',
        // imCs: 'http://im.yohobuy.com/api',
        // platformApi: 'http://172.16.6.210:8088/',
        // 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: false,
            name: 'info',
            level: 'info',
            filename: '/Data/logs/yoho-seo/info/info.log',
            maxFiles: 7
        },
        errorFile: {
            close: false,
            name: 'error',
            level: 'error',
            filename: '/Data/logs/yoho-seo/error/error.log',
            handleExceptions: true,
            maxFiles: 7
        },
        console: {
            level: 'debug',
            colorize: 'all',
            prettyPrint: true,
            debugStdout: 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,
    sessionMemcachedPrefix: 'yohobuy_session:',
    baiduToken: '0lSAO4ZxEKsYopMG', // 百度站长推送的token
    redis: {
        connect: {
            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;
                }
            }
        }
    },
    mysql: {
        host: '192.168.102.219',
        user: 'yh_test',
        password: 'yh_test',
        port: '3306',
        database: 'yoho_seo'
    },
    jobTask: [{
        k: 'global:yoho:task:minute',
        v: '1 */10 * * * *',
        info: '每10分钟执行一次'
    }, {
        k: 'global:yoho:task:day',
        v: '30 30 1 * * *',
        info: '每天的1点30分30s执行一次'
    }],
    sitemap: {
        pc: {
            host: 'https://www.yohobuy.com',
            dir: path.join(__dirname, '../xml/pc'),
            type: 'pc',
            props: ['lastmod', 'changefreq', 'priority']
        },
        h5: {
            host: 'https://m.yohobuy.com',
            dir: path.join(__dirname, '../xml/h5'),
            type: 'h5',
            props: ['lastmod', 'changefreq', 'priority', 'mobile']
        }
    }
};

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: '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;
                    }
                }
            }
        },
        mysql: {
            host: '10.66.106.5',
            user: 'yoho_seo_user',
            password: 'eRUWnPm6nqWT',
            port: '3306',
            database: 'yoho_seo'
        },
        sitemap: {
            pc: {
                host: 'https://www.yohobuy.com',
                dir: '/Data/yoho-seo/sitemap/pc',
                type: 'pc',
                props: ['lastmod', 'changefreq', 'priority']
            },
            h5: {
                host: 'https://m.yohobuy.com',
                dir: '/Data/yoho-seo/sitemap/h5',
                type: 'h5',
                props: ['lastmod', 'changefreq', 'priority', 'mobile']
            }
        }
    });
} 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
        }
    });
}