1
This commit is contained in:
parent
03a7c2bc2f
commit
95a53e9fb6
@ -114,7 +114,7 @@ bool App::Init(int argc, char* argv[])
|
|||||||
f8::HttpClientPool::Instance()->Init(10);
|
f8::HttpClientPool::Instance()->Init(10);
|
||||||
JsonDataMgr::Instance()->Init();
|
JsonDataMgr::Instance()->Init();
|
||||||
MetaMgr::Instance()->Init();
|
MetaMgr::Instance()->Init();
|
||||||
uuid.SetMachineId((node_id - 1) * 500 + instance_id);
|
uuid.SetMachineId((node_id - 1) * MAX_NODE_ID + instance_id);
|
||||||
RoomMgr::Instance()->Init();
|
RoomMgr::Instance()->Init();
|
||||||
PlayerMgr::Instance()->Init();
|
PlayerMgr::Instance()->Init();
|
||||||
GGListener::Instance()->Init();
|
GGListener::Instance()->Init();
|
||||||
|
@ -73,7 +73,15 @@ void App::Init(int argc, char* argv[])
|
|||||||
|
|
||||||
if (!ParseOpt()) {
|
if (!ParseOpt()) {
|
||||||
terminated = true;
|
terminated = true;
|
||||||
a8::XPrintf("masterserver启动失败,缺少-i参数\n", {});
|
if (node_id <= 0) {
|
||||||
|
a8::XPrintf("gameserver启动失败,缺少-n参数\n", {});
|
||||||
|
} else if (node_id > MAX_NODE_ID) {
|
||||||
|
a8::XPrintf("gameserver启动失败,-n参数不能大于%d\n", {MAX_NODE_ID});
|
||||||
|
} else if (instance_id <= 0) {
|
||||||
|
a8::XPrintf("gameserver启动失败,缺少-i参数\n", {});
|
||||||
|
} else if (instance_id > MAX_INSTANCE_ID) {
|
||||||
|
a8::XPrintf("gameserver启动失败,-i参数不能大于%d\n", {MAX_INSTANCE_ID});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a8::XPrintf("masterserver starting instance_id:%d pid:%d game_id:%d\n", {instance_id, getpid(), GAME_ID});
|
a8::XPrintf("masterserver starting instance_id:%d pid:%d game_id:%d\n", {instance_id, getpid(), GAME_ID});
|
||||||
@ -91,7 +99,7 @@ void App::Init(int argc, char* argv[])
|
|||||||
f8::TGLog::Instance()->Init(a8::Format(PROJ_NAME_FMT, {GAME_ID}), false);
|
f8::TGLog::Instance()->Init(a8::Format(PROJ_NAME_FMT, {GAME_ID}), false);
|
||||||
f8::HttpClientPool::Instance()->Init(10);
|
f8::HttpClientPool::Instance()->Init(10);
|
||||||
JsonDataMgr::Instance()->Init();
|
JsonDataMgr::Instance()->Init();
|
||||||
uuid.SetMachineId(instance_id);
|
uuid.SetMachineId((node_id - 1) * MAX_NODE_ID + instance_id);
|
||||||
GGListener::Instance()->Init();
|
GGListener::Instance()->Init();
|
||||||
|
|
||||||
a8::UdpLog::Instance()->Info("masterserver starting instance_id:%d pid:%d", {instance_id, getpid()});
|
a8::UdpLog::Instance()->Info("masterserver starting instance_id:%d pid:%d", {instance_id, getpid()});
|
||||||
@ -413,8 +421,13 @@ void App::UnInitLog()
|
|||||||
bool App::ParseOpt()
|
bool App::ParseOpt()
|
||||||
{
|
{
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
while ((ch = getopt(argc, argv, "i:t:r:f:")) != -1) {
|
while ((ch = getopt(argc, argv, "n:i:t:r:f:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case 'n':
|
||||||
|
{
|
||||||
|
node_id = a8::XValue(optarg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
instance_id = a8::XValue(optarg);
|
instance_id = a8::XValue(optarg);
|
||||||
@ -437,7 +450,7 @@ bool App::ParseOpt()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return instance_id > 0;
|
return instance_id > 0 && node_id > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long App::NewUuid()
|
long long App::NewUuid()
|
||||||
|
@ -57,6 +57,7 @@ public:
|
|||||||
a8::uuid::SnowFlake uuid;
|
a8::uuid::SnowFlake uuid;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
int node_id = 0;
|
||||||
int instance_id = 0;
|
int instance_id = 0;
|
||||||
bool is_test_mode = false;
|
bool is_test_mode = false;
|
||||||
int test_param = 0;
|
int test_param = 0;
|
||||||
|
@ -144,3 +144,6 @@ const int MAP_WIDTH = 8192;
|
|||||||
const int MAP_CELL_WIDTH = 64 * 8;
|
const int MAP_CELL_WIDTH = 64 * 8;
|
||||||
|
|
||||||
const int DOOR_THING_ID = 61701;
|
const int DOOR_THING_ID = 61701;
|
||||||
|
|
||||||
|
const int MAX_NODE_ID = 8;
|
||||||
|
const int MAX_INSTANCE_ID = 500;
|
||||||
|
@ -41,6 +41,8 @@ void GSMgr::___GSReport(f8::JsonHttpRequest* request)
|
|||||||
int port = request->request.Get("port");
|
int port = request->request.Get("port");
|
||||||
int online_num = request->request.Get("online_num");
|
int online_num = request->request.Get("online_num");
|
||||||
int room_num = request->request.Get("room_num");
|
int room_num = request->request.Get("room_num");
|
||||||
|
int instance_id = request->request.Get("instance_id");
|
||||||
|
int node_id = request->request.Get("node_id");
|
||||||
std::string key = ip + a8::XValue(port).GetString();
|
std::string key = ip + a8::XValue(port).GetString();
|
||||||
|
|
||||||
auto itr = node_key_hash_.find(key);
|
auto itr = node_key_hash_.find(key);
|
||||||
@ -49,7 +51,8 @@ void GSMgr::___GSReport(f8::JsonHttpRequest* request)
|
|||||||
itr->second.room_num = room_num;
|
itr->second.room_num = room_num;
|
||||||
} else {
|
} else {
|
||||||
GSNode gs;
|
GSNode gs;
|
||||||
gs.key = key;
|
gs.node_id = node_id;
|
||||||
|
gs.instance_id = instance_id;
|
||||||
gs.online_num = online_num;
|
gs.online_num = online_num;
|
||||||
gs.room_num = room_num;
|
gs.room_num = room_num;
|
||||||
gs.ip = ip;
|
gs.ip = ip;
|
||||||
|
@ -6,10 +6,13 @@ struct GSNode
|
|||||||
{
|
{
|
||||||
std::string key;
|
std::string key;
|
||||||
unsigned short node_idx = 0;
|
unsigned short node_idx = 0;
|
||||||
|
int node_id = 0;
|
||||||
|
int instance_id = 0;
|
||||||
int room_num = 0;
|
int room_num = 0;
|
||||||
int online_num = 0;
|
int online_num = 0;
|
||||||
std::string ip;
|
std::string ip;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
|
bool servicing = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GSMgr : public a8::Singleton<GSMgr>
|
class GSMgr : public a8::Singleton<GSMgr>
|
||||||
|
@ -10,21 +10,30 @@ void JsonDataMgr::Init()
|
|||||||
std::string masterserver_cluster_json_file;
|
std::string masterserver_cluster_json_file;
|
||||||
if (!f8::IsOnlineEnv()) {
|
if (!f8::IsOnlineEnv()) {
|
||||||
if (App::Instance()->flags.find(2) != App::Instance()->flags.end()) {
|
if (App::Instance()->flags.find(2) != App::Instance()->flags.end()) {
|
||||||
masterserver_cluster_json_file = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver/"
|
masterserver_cluster_json_file = a8::Format("/root/pub/%d/%d/conf_test/game%d/masterserver/node%d/"
|
||||||
"game%d.masterserver.cluster.json",
|
"game%d.masterserver.cluster.json",
|
||||||
{
|
{
|
||||||
GAME_ID,
|
GAME_ID,
|
||||||
App::Instance()->instance_id,
|
App::Instance()->instance_id,
|
||||||
GAME_ID,
|
GAME_ID,
|
||||||
|
App::Instance()->node_id,
|
||||||
GAME_ID
|
GAME_ID
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
masterserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/masterserver/"
|
masterserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/masterserver/node%d/"
|
||||||
"game%d.masterserver.cluster.json",
|
"game%d.masterserver.cluster.json",
|
||||||
{GAME_ID, GAME_ID});
|
{
|
||||||
|
GAME_ID,
|
||||||
|
App::Instance()->node_id,
|
||||||
|
GAME_ID
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
masterserver_cluster_json_file = a8::Format("../config/game%d.masterserver.cluster.json", {GAME_ID});
|
masterserver_cluster_json_file = a8::Format("../config/node%d/game%d.masterserver.cluster.json",
|
||||||
|
{
|
||||||
|
App::Instance()->node_id,
|
||||||
|
GAME_ID
|
||||||
|
});
|
||||||
}
|
}
|
||||||
masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file);
|
masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user