根据 chat 示例创建 game-server,支持分布式部署、域名访问、数据库连接和基础使用
This commit is contained in:
11
game-server/config/adminServer.ts
Normal file
11
game-server/config/adminServer.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = [{
|
||||
'type': 'connector',
|
||||
'token': 'agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn'
|
||||
}, {
|
||||
'type': 'chat',
|
||||
'token': 'agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn'
|
||||
}, {
|
||||
'type': 'gate',
|
||||
'token': 'agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn'
|
||||
}
|
||||
];
|
||||
17
game-server/config/adminUser.ts
Normal file
17
game-server/config/adminUser.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
module.exports = [{
|
||||
'id': 'user-1',
|
||||
'username': 'admin',
|
||||
'password': 'admin',
|
||||
'level': 1
|
||||
}, {
|
||||
'id': 'user-2',
|
||||
'username': 'monitor',
|
||||
'password': 'monitor',
|
||||
'level': 2
|
||||
}, {
|
||||
'id': 'user-3',
|
||||
'username': 'test',
|
||||
'password': 'test',
|
||||
'level': 2
|
||||
}
|
||||
];
|
||||
14
game-server/config/clientProtos.ts
Normal file
14
game-server/config/clientProtos.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
"chat.chatHandler.send": {
|
||||
"required string content": 1,
|
||||
"required string target": 2,
|
||||
"required string rid": 3,
|
||||
"required string from": 4,
|
||||
},
|
||||
"chat.chatHandler.send2": {
|
||||
"required string rid": 1,
|
||||
"required string content": 2,
|
||||
"required string from": 3,
|
||||
"required string target": 4
|
||||
},
|
||||
};
|
||||
1
game-server/config/dictionary.ts
Normal file
1
game-server/config/dictionary.ts
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = [];
|
||||
134
game-server/config/log4js.ts
Normal file
134
game-server/config/log4js.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
module.exports = {
|
||||
'appenders': {
|
||||
'console': {
|
||||
'type': 'console'
|
||||
},
|
||||
'con-log': {
|
||||
'type': 'file',
|
||||
'filename': '${opts:base}/logs/con-log-${opts:serverId}.log',
|
||||
'pattern': 'connector',
|
||||
'maxLogSize': 1048576,
|
||||
'layout': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'backups': 5
|
||||
},
|
||||
'rpc-log': {
|
||||
'type': 'file',
|
||||
'filename': '${opts:base}/logs/rpc-log-${opts:serverId}.log',
|
||||
'maxLogSize': 1048576,
|
||||
'layout': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'backups': 5
|
||||
},
|
||||
'forward-log': {
|
||||
'type': 'file',
|
||||
'filename': '${opts:base}/logs/forward-log-${opts:serverId}.log',
|
||||
'maxLogSize': 1048576,
|
||||
'layout': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'backups': 5
|
||||
},
|
||||
'rpc-debug': {
|
||||
'type': 'file',
|
||||
'filename': '${opts:base}/logs/rpc-debug-${opts:serverId}.log',
|
||||
'maxLogSize': 1048576,
|
||||
'layout': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'backups': 5
|
||||
},
|
||||
'crash-log': {
|
||||
'type': 'file',
|
||||
'filename': '${opts:base}/logs/crash.log',
|
||||
'maxLogSize': 1048576,
|
||||
'layout': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'backups': 5
|
||||
},
|
||||
'admin-log': {
|
||||
'type': 'file',
|
||||
'filename': '${opts:base}/logs/admin.log',
|
||||
'maxLogSize': 1048576,
|
||||
'layout': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'backups': 5
|
||||
},
|
||||
'pinus': {
|
||||
'type': 'file',
|
||||
'filename': '${opts:base}/logs/pinus-${opts:serverId}.log',
|
||||
'maxLogSize': 1048576,
|
||||
'layout': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'backups': 5
|
||||
},
|
||||
'pinus-admin': {
|
||||
'type': 'file',
|
||||
'filename': '${opts:base}/logs/pinus-admin.log',
|
||||
'maxLogSize': 1048576,
|
||||
'layout': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'backups': 5
|
||||
},
|
||||
'pinus-rpc': {
|
||||
'type': 'file',
|
||||
'filename': '${opts:base}/logs/pinus-rpc-${opts:serverId}.log',
|
||||
'maxLogSize': 1048576,
|
||||
'layout': {
|
||||
'type': 'basic'
|
||||
},
|
||||
'backups': 5
|
||||
}
|
||||
},
|
||||
|
||||
'categories': {
|
||||
'default': {
|
||||
'appenders': ['console', 'pinus'],
|
||||
'level': 'debug'
|
||||
},
|
||||
'con-log': {
|
||||
'appenders': ['con-log'],
|
||||
'level': 'debug'
|
||||
},
|
||||
'rpc-log': {
|
||||
'appenders': ['rpc-log'],
|
||||
'level': 'debug'
|
||||
},
|
||||
'forward-log': {
|
||||
'appenders': ['forward-log'],
|
||||
'level': 'debug'
|
||||
},
|
||||
'rpc-debug': {
|
||||
'appenders': ['rpc-debug'],
|
||||
'level': 'debug'
|
||||
},
|
||||
'crash-log': {
|
||||
'appenders': ['crash-log'],
|
||||
'level': 'debug'
|
||||
},
|
||||
'admin-log': {
|
||||
'appenders': ['admin-log'],
|
||||
'level': 'debug'
|
||||
},
|
||||
'pinus-admin': {
|
||||
'appenders': ['pinus-admin'],
|
||||
'level': 'debug'
|
||||
},
|
||||
'pinus-rpc': {
|
||||
'appenders': ['pinus-rpc'],
|
||||
'level': 'debug'
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
'prefix': '${opts:serverId} ',
|
||||
'replaceConsole': true,
|
||||
'lineDebug': false,
|
||||
'errorStack': true
|
||||
};
|
||||
30
game-server/config/log4js.without.logfile.ts
Normal file
30
game-server/config/log4js.without.logfile.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
// 不写日志文件 示例配置文件。
|
||||
|
||||
module.exports = {
|
||||
'appenders': {
|
||||
'displayConsole': {
|
||||
'type': 'console'
|
||||
},
|
||||
// "other": {
|
||||
// "type": "file",
|
||||
// "filename": "${opts:base}/logs/${opts:serverId}.log",
|
||||
// "maxLogSize": 1048576,
|
||||
// "layout": {
|
||||
// "type": "basic"
|
||||
// },
|
||||
// "backups": 5
|
||||
// }
|
||||
},
|
||||
'categories': {
|
||||
'default': {
|
||||
'appenders': [
|
||||
/*"other",*/'displayConsole'
|
||||
],
|
||||
'level': 'debug'
|
||||
}
|
||||
},
|
||||
'replaceConsole': true,
|
||||
'prefix': '${opts:serverId} ',
|
||||
'lineDebug': false,
|
||||
'errorStack': true
|
||||
};
|
||||
13
game-server/config/master.ts
Normal file
13
game-server/config/master.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'development': {
|
||||
'id': 'master-server-1',
|
||||
'host': '127.0.0.1',
|
||||
'port': 3005
|
||||
},
|
||||
|
||||
'production': {
|
||||
'id': 'master-server-1',
|
||||
'host': '127.0.0.1',
|
||||
'port': 3005
|
||||
}
|
||||
};
|
||||
7
game-server/config/serverProtos.ts
Normal file
7
game-server/config/serverProtos.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
'onChat': {
|
||||
'required string msg': 1,
|
||||
'required string from': 2,
|
||||
'required string target': 3
|
||||
},
|
||||
};
|
||||
45
game-server/config/servers.ts
Normal file
45
game-server/config/servers.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
module.exports = {
|
||||
'development': {
|
||||
'connector': [
|
||||
{
|
||||
'id': 'connector-server-1',
|
||||
'host': '127.0.0.1',
|
||||
'port': 4050,
|
||||
'clientHost': 'pinus_test.trgame.cn',
|
||||
'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'}
|
||||
],
|
||||
'gate': [
|
||||
{
|
||||
'id': 'gate-server-1',
|
||||
'host': '127.0.0.1',
|
||||
'clientHost': 'pinus_test.trgame.cn',
|
||||
'clientPort': 3014,
|
||||
'frontend': true,
|
||||
'args': '--inspect=10003'
|
||||
}
|
||||
]
|
||||
},
|
||||
'production': {
|
||||
'connector': [
|
||||
{'id': 'connector-server-1', 'port': 4050, 'host': 'pinus_test.trgame.cn', 'clientPort': 3050, 'frontend': true},
|
||||
{'id': 'connector-server-2', 'port': 4051, 'host': 'pinus_test.trgame.cn', 'clientPort': 3051, 'frontend': true},
|
||||
{'id': 'connector-server-3', 'port': 4052, 'host': 'pinus_test.trgame.cn', 'clientPort': 3052, 'frontend': true}
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050},
|
||||
{'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051},
|
||||
{'id': 'chat-server-3', 'host': '127.0.0.1', 'port': 6052}
|
||||
],
|
||||
'gate': [
|
||||
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'pinus_test.trgame.cn', 'clientPort': 3014, 'frontend': true}
|
||||
]
|
||||
}
|
||||
};
|
||||
45
game-server/config/servers_multi_ser.ts
Normal file
45
game-server/config/servers_multi_ser.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
module.exports = {
|
||||
'development': {
|
||||
'connector': [
|
||||
{
|
||||
'id': 'connector-server-1',
|
||||
// 'host': '127.0.0.1',
|
||||
'host': '39.101.222.20',
|
||||
'port': 4050,
|
||||
'clientHost': '39.101.222.20',
|
||||
'clientPort': 3050,
|
||||
'frontend': true,
|
||||
'args': '--inspect=10001'
|
||||
}
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '39.101.222.20', 'port': 6050, 'args': '--inspect=10002'},
|
||||
{'id': 'chat-server-2', 'host': '39.100.68.60', 'port': 6051, 'args': '--inspect=10004'},
|
||||
{'id': 'chat-server-3', 'host': '39.100.68.60', 'port': 6052, 'args': '--inspect=10005'}
|
||||
],
|
||||
'gate': [
|
||||
{
|
||||
'id': 'gate-server-1',
|
||||
'host': '39.101.222.20',
|
||||
'clientPort': 3014,
|
||||
'frontend': true,
|
||||
'args': '--inspect=10003'
|
||||
}
|
||||
]
|
||||
},
|
||||
'production': {
|
||||
'connector': [
|
||||
{'id': 'connector-server-1', 'host': '127.0.0.1', 'port': 4050, 'clientPort': 3050, 'frontend': true},
|
||||
{'id': 'connector-server-2', 'host': '127.0.0.1', 'port': 4051, 'clientPort': 3051, 'frontend': true},
|
||||
{'id': 'connector-server-3', 'host': '127.0.0.1', 'port': 4052, 'clientPort': 3052, 'frontend': true}
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050},
|
||||
{'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051},
|
||||
{'id': 'chat-server-3', 'host': '39.100.68.60', 'port': 6052}
|
||||
],
|
||||
'gate': [
|
||||
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientPort': 3014, 'frontend': true}
|
||||
]
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user