添加环境变量local

This commit is contained in:
luying
2020-10-16 17:52:54 +08:00
parent f6509532ac
commit df879279cb
4 changed files with 61 additions and 6 deletions

View File

@@ -39,8 +39,15 @@ adminfilePath.ADMIN_USER = 'config/adminUser';
*/
preload();
let mongoAddr = 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098';
let redisArr = 'r-8vb4i2kgl91886fkxd.redis.zhangbei.rds.aliyuncs.com';
if(process.env.NODE_ENV == 'local') {
mongoAddr = 'mongodb://127.0.0.1/admin';
redisArr = '127.0.0.1';
}
// 创建 mongodb 连接
mongoose.connect('mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098', { useNewUrlParser: true, useUnifiedTopology: true }, (err) => {
mongoose.connect(mongoAddr, { useNewUrlParser: true, useUnifiedTopology: true }, (err) => {
if (err) {
console.log('mongodb connect err', err);
} else {
@@ -49,7 +56,7 @@ mongoose.connect('mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhan
});
// 创建 redis 连接
const client = redis.createClient(6379, 'r-8vb4i2kgl91886fkxd.redis.zhangbei.rds.aliyuncs.com', {detect_buffers: true});
const client = redis.createClient(6379, redisArr, {detect_buffers: true});
client.auth('zyz_2020', (err, reply) => {
if (err) {
console.log('redis err', err);
@@ -66,7 +73,7 @@ let app = pinus.createApp();
app.set('name', 'chatofpomelo-websocket');
// app configuration
app.configure('production|development', 'connector', function () {
app.configure('production|development|local', 'connector', function () {
app.set('connectorConfig',
{
connector: pinus.connectors.hybridconnector,
@@ -91,7 +98,7 @@ app.configure('production|development', 'connector', function () {
});
});
app.configure('production|development', 'gate', function () {
app.configure('production|development|local', 'gate', function () {
app.set('connectorConfig',
{
connector: pinus.connectors.hybridconnector,
@@ -163,7 +170,7 @@ app.configure('production|development', function () {
});
});
app.configure('development', function () {
app.configure('development|local', function () {
// enable the system monitor modules
app.enable('systemMonitor');
app.enable('rpcDebugLog');

View File

@@ -9,5 +9,10 @@ module.exports = {
'id': 'master-server-1',
'host': '127.0.0.1',
'port': 3005
},
'local': {
'id': 'master-server-1',
'host': '127.0.0.1',
'port': 3005
}
};

View File

@@ -68,5 +68,47 @@ module.exports = {
'frontend': true
}
]
},
'local': {
'connector': [
{
'id': 'connector-server-1',
'host': '127.0.0.1',
'port': 4050,
'clientHost': '127.0.0.1',
'clientPort': 3050,
'frontend': true,
'args': '--inspect=10001'
}
],
'chat': [
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050, 'args': '--inspect=10002'},
{'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051, 'args': '--inspect=10004'},
{'id': 'chat-server-3', 'host': '127.0.0.1', 'port': 6052, 'args': '--inspect=10005'}
],
'role': [
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053, 'args': '--inspect=10006'}
],
'battle': [
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054, 'args': '--inspect=10007'}
],
'gate': [
{
'id': 'gate-server-1',
'host': '127.0.0.1',
'clientHost': '127.0.0.1',
'clientPort': 3014,
'frontend': true,
'args': '--inspect=10003'
},
{
'id': 'gate-server-2',
'host': '127.0.0.1',
'clientHost': '127.0.0.1',
'clientPort': 3015,
'frontend': true,
'args': '--inspect=10008'
}
]
}
};

View File

@@ -10,7 +10,8 @@
"test": "yarn run build",
"cov": "nyc mocha",
"ci": "yarn run test",
"gen-api-ref": "node ../../../node_modules/typedoc/bin/typedoc --mode file --hideGenerator --excludeExternals --ignoreCompilerErrors --out ../../../run/site/public/api-reference/pinus-loader lib/"
"gen-api-ref": "node ../../../node_modules/typedoc/bin/typedoc --mode file --hideGenerator --excludeExternals --ignoreCompilerErrors --out ../../../run/site/public/api-reference/pinus-loader lib/",
"local": "npm run build && cd dist && NODE_ENV=local pinus start -e local"
},
"dependencies": {
"@typegoose/typegoose": "^7.3.5",