环境:增加监控服务器配置
部署:修改 pm2 启动相关文件
This commit is contained in:
+2
-1
@@ -1,3 +1,4 @@
|
||||
require('xprofiler').start();
|
||||
import { COM_TEAM_STATUS } from './app/consts';
|
||||
import {
|
||||
createTcpAcceptor,
|
||||
@@ -38,7 +39,7 @@ filePath.CONFIG_DIR = '/config';
|
||||
const adminfilePath = _pinus.DEFAULT_ADMIN_PATH;
|
||||
adminfilePath.ADMIN_FILENAME = 'adminUser';
|
||||
adminfilePath.ADMIN_USER = 'config/adminUser';
|
||||
const ALL_ENVS = 'production|development|alpha|dev|isbn';
|
||||
const ALL_ENVS = 'production|development|alpha|dev|isbn|monitor';
|
||||
/**
|
||||
* 替换全局Promise
|
||||
* 自动解析sourcemap
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"env":"alpha"}
|
||||
{"env":"development"}
|
||||
|
||||
@@ -24,5 +24,10 @@ module.exports = {
|
||||
'mongo': 'mongodb://root:Bantus123@dds-8vb74337eab84d641.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb74337eab84d642.mongodb.zhangbei.rds.aliyuncs.com:3717/admin?replicaSet=mgset-504694158',
|
||||
'redis': 'r-8vbekkbb3z8ru2ckuj.redis.zhangbei.rds.aliyuncs.com',
|
||||
'redispw': 'zyz_isbn_2021'
|
||||
},
|
||||
'monitor': {
|
||||
'mongo': 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-505529944',
|
||||
'redis': 'r-8vb130185rp2ir3lqn.redis.zhangbei.rds.aliyuncs.com',
|
||||
'redispw': 'zyz_monitor_2021'
|
||||
}
|
||||
};
|
||||
@@ -23,5 +23,10 @@ module.exports = {
|
||||
'id': 'master-server-1',
|
||||
'host': '127.0.0.1',
|
||||
'port': 3005
|
||||
},
|
||||
'monitor': {
|
||||
'id': 'master-server-1',
|
||||
'host': '127.0.0.1',
|
||||
'port': 3005
|
||||
}
|
||||
};
|
||||
@@ -197,5 +197,35 @@ module.exports = {
|
||||
{'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239"},
|
||||
{'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240"}
|
||||
]
|
||||
},
|
||||
'monitor': {
|
||||
'connector': [
|
||||
{'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyz_monitor.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true},
|
||||
{'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyz_monitor.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true},
|
||||
{'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyz_monitor.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true}
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050},
|
||||
],
|
||||
'role': [
|
||||
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053}
|
||||
],
|
||||
'battle': [
|
||||
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054}
|
||||
],
|
||||
'gate': [
|
||||
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyz_monitor.trgame.cn', 'clientPort': 3014, 'frontend': true},
|
||||
{'id': 'gate-server-2', 'host': '127.0.0.1', 'clientHost': 'zyz_monitor.trgame.cn', 'clientPort': 3015, 'frontend': true}
|
||||
],
|
||||
'gm': [
|
||||
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055}
|
||||
],
|
||||
'systimer': [
|
||||
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056}
|
||||
],
|
||||
'guild': [
|
||||
{'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239"},
|
||||
{'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240"}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
Generated
+41
@@ -1799,6 +1799,11 @@
|
||||
"thenify-all": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.14.2",
|
||||
"resolved": "https://registry.npm.taobao.org/nan/download/nan-2.14.2.tgz?cache=0&sync_timestamp=1602591700047&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnan%2Fdownload%2Fnan-2.14.2.tgz",
|
||||
"integrity": "sha1-9TdkAGlRaPTMaUrJOT0MlYXu6hk="
|
||||
},
|
||||
"nanoid": {
|
||||
"version": "3.1.12",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.12.tgz",
|
||||
@@ -2979,6 +2984,42 @@
|
||||
"resolved": "https://registry.npm.taobao.org/xmlhttprequest-ssl/download/xmlhttprequest-ssl-1.5.5.tgz?cache=0&sync_timestamp=1564594177335&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fxmlhttprequest-ssl%2Fdownload%2Fxmlhttprequest-ssl-1.5.5.tgz",
|
||||
"integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4="
|
||||
},
|
||||
"xprofiler": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npm.taobao.org/xprofiler/download/xprofiler-1.2.5.tgz",
|
||||
"integrity": "sha1-ugaj1UMv9zIoQR6mhsNTnMWWTsQ=",
|
||||
"requires": {
|
||||
"moment": "^2.29.1",
|
||||
"nan": "^2.14.2",
|
||||
"node-pre-gyp": "^0.16.0",
|
||||
"uuid": "^8.3.1",
|
||||
"yargs": "^15.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-pre-gyp": {
|
||||
"version": "0.16.0",
|
||||
"resolved": "https://registry.npm.taobao.org/node-pre-gyp/download/node-pre-gyp-0.16.0.tgz?cache=0&sync_timestamp=1612890864161&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnode-pre-gyp%2Fdownload%2Fnode-pre-gyp-0.16.0.tgz",
|
||||
"integrity": "sha1-I4+lQDZHhOUBXfzbp42jk34Y29w=",
|
||||
"requires": {
|
||||
"detect-libc": "^1.0.2",
|
||||
"mkdirp": "^0.5.3",
|
||||
"needle": "^2.5.0",
|
||||
"nopt": "^4.0.1",
|
||||
"npm-packlist": "^1.1.6",
|
||||
"npmlog": "^4.0.2",
|
||||
"rc": "^1.2.7",
|
||||
"rimraf": "^2.6.1",
|
||||
"semver": "^5.3.0",
|
||||
"tar": "^4.4.2"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npm.taobao.org/uuid/download/uuid-8.3.2.tgz?cache=0&sync_timestamp=1607460209394&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fuuid%2Fdownload%2Fuuid-8.3.2.tgz",
|
||||
"integrity": "sha1-gNW1ztJxu5r2xEXyGhoExgbO++I="
|
||||
}
|
||||
}
|
||||
},
|
||||
"xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npm.taobao.org/xtend/download/xtend-4.0.2.tgz",
|
||||
|
||||
@@ -50,7 +50,8 @@
|
||||
"request": "^2.88.2",
|
||||
"request-promise": "^4.2.6",
|
||||
"source-map-support": "^0.5.0",
|
||||
"ts-node": "^8.2.0"
|
||||
"ts-node": "^8.2.0",
|
||||
"xprofiler": "^1.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node-schedule": "^1.3.1",
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* Created by superzhan on 2018/3/19.
|
||||
*
|
||||
* 根据pomelo 的 servers.json 生成 pm2 启动文件
|
||||
*/
|
||||
|
||||
//服务器端 工程代码的目录
|
||||
var cwd='./';
|
||||
|
||||
//项目的运行环境
|
||||
var config = require('./config.json');
|
||||
var envType= config.env;
|
||||
|
||||
//配置文件的输出目录
|
||||
var outputFilePath = './pomeloPm2Start.json';
|
||||
|
||||
var masterJsonFile = require('./config/master.ts');
|
||||
var serversJosnFile = require('./config/servers.ts');
|
||||
|
||||
//模板数据
|
||||
var processConfigType = {
|
||||
"name" : "",
|
||||
"script" : "./dist/app.js",
|
||||
"args" : [] ,
|
||||
"watch": false,
|
||||
"out_file": "./logs/app.log",
|
||||
"error_file": "./logs/err.log",
|
||||
"cwd": "",
|
||||
"merge_logs": true,
|
||||
"exec_mode": "fork_mode",
|
||||
};
|
||||
|
||||
|
||||
//最后的结果数据
|
||||
var resultJson={};
|
||||
resultJson.apps=new Array();
|
||||
|
||||
|
||||
var clone = function(origin) {
|
||||
if(!origin) {
|
||||
return;
|
||||
}
|
||||
var obj = {};
|
||||
for(var f in origin) {
|
||||
obj[f] = origin[f];
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
//
|
||||
var masterConfig = masterJsonFile[envType];
|
||||
var serversConfig = serversJosnFile[envType];
|
||||
|
||||
//生成master 的配置
|
||||
var pm2Master = clone( processConfigType );
|
||||
pm2Master.name="master";
|
||||
pm2Master.args = new Array();
|
||||
pm2Master.args.push('serverType=master');
|
||||
pm2Master.args.push('id='+masterConfig.id);
|
||||
pm2Master.args.push('host='+masterConfig.host);
|
||||
pm2Master.args.push('port='+masterConfig.port);
|
||||
pm2Master.args.push('env='+envType);
|
||||
pm2Master.args.push('mode=stand-alone');
|
||||
pm2Master.cwd= cwd;
|
||||
pm2Master.out_file = './logs/'+masterConfig.id+"_app.log";
|
||||
pm2Master.error_file='./logs/'+masterConfig.id+'_error.log';
|
||||
resultJson.apps.push(pm2Master);
|
||||
|
||||
//生成当个服务器的配置
|
||||
for(serverType in serversConfig)
|
||||
{
|
||||
var servers = serversConfig[serverType];
|
||||
for(var i=0;i<servers.length;++i)
|
||||
{
|
||||
var singleServer= servers[i];
|
||||
|
||||
var appPm2Config = clone(processConfigType);
|
||||
appPm2Config.name=singleServer.id;
|
||||
appPm2Config.args= new Array();
|
||||
appPm2Config.args.push('env='+envType);
|
||||
appPm2Config.args.push('id='+singleServer.id);
|
||||
appPm2Config.args.push('port='+singleServer.port);
|
||||
appPm2Config.args.push('host='+singleServer.host);
|
||||
appPm2Config.args.push('serverType='+serverType);
|
||||
|
||||
if(singleServer.frontend !=null)
|
||||
{
|
||||
appPm2Config.args.push('frontend='+ singleServer.frontend);
|
||||
appPm2Config.args.push('clientPort='+singleServer.clientPort);
|
||||
appPm2Config.args.push('clientHost='+singleServer.clientHost);
|
||||
}
|
||||
|
||||
appPm2Config.cwd= cwd;
|
||||
appPm2Config.out_file = './logs/'+ singleServer.id+'_app.log';
|
||||
appPm2Config.error_file = './logs/'+singleServer.id+'_error.log';
|
||||
|
||||
resultJson.apps.push(appPm2Config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//生成结果数据
|
||||
var resultFileStr = JSON.stringify(resultJson);
|
||||
//console.log(resultFileStr);
|
||||
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
fs.writeFile(outputFilePath, resultFileStr, function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log('finish genereate Server pm2 config');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#/bin/bash
|
||||
npm install #安装依赖库
|
||||
npm run build
|
||||
node pm2Config.js #使用pm2来做进程管理,生成进程配置文件
|
||||
pm2 start pomeloPm2Start.json #pm2 启动游戏服务器
|
||||
Reference in New Issue
Block a user