Compare commits

..

4 Commits
dev ... master

Author SHA1 Message Date
aozhiwei
aea850d36e 添加SSPong处理 2020-05-11 13:47:49 +08:00
aozhiwei
e7219df9a5 1 2019-12-16 20:20:42 +08:00
aozhiwei
a27bd57c6e 1 2019-12-16 19:56:14 +08:00
aozhiwei
9fb79fdefb 1 2019-12-16 19:49:45 +08:00
11 changed files with 93 additions and 63 deletions

11
server/bin/monitor.sh Normal file
View File

@ -0,0 +1,11 @@
path_arr=$(echo $PWD|tr '/' '\n')
path_arr=(${path_arr})
GAME_ID=${path_arr[-5]}
if echo $GAME_ID | grep -q '[^0-9]'
then
echo 'game_id参数必须为数字'
exit 1
fi
python ../../third_party/tools/scripts/server/monitor.py gameserver${GAME_ID} '-n1 -i1'

View File

@ -1,30 +0,0 @@
# -*- coding: utf-8 -*-
import os
import time
def getRuningProgramPids(progname):
pids = []
lines = os.popen('ps -ef | grep %s' % progname).readlines()
for l in lines:
line = ''
oldc = ''
for c in l.strip():
if c in [' ', '\t'] and c == oldc:
continue
oldc = c
line += c
line = line.split(' ')
if line[7] == './%s' % progname:
pids.append(line[1])
return pids
def monitor_gs():
while True:
pids = getRuningProgramPids('gameserver2002')
if len(pids) <= 0:
print('zzzz')
os.popen('nohup ./gameserver2002 -n1 -i1 -f1,2,4>> gameserver2002.out 2>&1 &')
time.sleep(2)
monitor_gs()

View File

@ -3,10 +3,15 @@ cmake_minimum_required(VERSION 2.8)
set(GAME_ID 2002)
set(CMAKE_BUILD_TYPE "Debug")
#set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -std=gnu++11 -DGAME_ID=${GAME_ID}")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID}")
if (${RELEASE})
set(CMAKE_BUILD_TYPE "Release")
message("release mode")
else()
set(CMAKE_BUILD_TYPE "Debug")
message("debug mode")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DDEBUG")
include_directories(
AFTER
@ -19,6 +24,7 @@ include_directories(
../../third_party
../../third_party/behaviac/inc
../../third_party/recastnavigation/Detour/Include
../../third_party/recastnavigation/DetourTileCache/Include
.
)
@ -40,6 +46,9 @@ aux_source_directory(../../third_party/recastnavigation/Detour/Source
SRC_LIST
)
aux_source_directory(../../third_party/recastnavigation/DetourTileCache/Source
SRC_LIST
)
execute_process(
COMMAND touch -a cs_proto.pb.h
@ -62,7 +71,7 @@ set(EXECUTABLE_OUTPUT_PATH
)
add_executable(
gameserver ${SRC_LIST}
gameserver${GAME_ID} ${SRC_LIST}
)
add_custom_target(script_pb_protocol ALL)
@ -70,21 +79,42 @@ add_custom_command(TARGET script_pb_protocol
PRE_BUILD
COMMAND python ../../third_party/tools/scripts/construct/build_pb.py --cpp_out=. --pb_files=cs_proto,cs_msgid,ss_proto,ss_msgid,metatable --python_out=../tools/robot/virtualclient
)
add_dependencies(gameserver script_pb_protocol)
add_dependencies(gameserver${GAME_ID} script_pb_protocol)
target_link_libraries(
gameserver
pthread
mysqlclient
protobuf
rt
dl
util
crypto
ssl
jsoncpp
curl
hiredis
tinyxml2
behaviac_gcc_release
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_libraries(
gameserver${GAME_ID}
pthread
mysqlclient
protobuf
rt
dl
util
crypto
ssl
jsoncpp
curl
hiredis
tinyxml2
tcmalloc
behaviac_gcc_debug
)
else()
target_link_libraries(
gameserver${GAME_ID}
pthread
mysqlclient
protobuf
rt
dl
util
crypto
ssl
jsoncpp
curl
hiredis
tinyxml2
tcmalloc
behaviac_gcc_release
)
endif()

View File

@ -81,6 +81,7 @@ void HandlerMgr::UnInit()
void HandlerMgr::RegisterNetMsgHandlers()
{
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_WSP_SocketDisconnect);
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_Ping);
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMJoin);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMove);

View File

@ -7,13 +7,22 @@
void JsonDataMgr::Init()
{
if (!f8::IsOnlineEnv() && App::Instance()->HasFlag(2)) {
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver",
{
GAME_ID,
App::Instance()->instance_id,
GAME_ID
});
if (!f8::IsOnlineEnv()) {
if (f8::IsTestEnv()) {
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.test",
{
GAME_ID,
App::Instance()->instance_id,
GAME_ID
});
} else {
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.dev",
{
GAME_ID,
App::Instance()->instance_id,
GAME_ID
});
}
}
std::string gameserver_cluster_json_file;
gameserver_cluster_json_file = a8::Format("%s/node%d/game%d.gameserver.cluster.json",

View File

@ -3,6 +3,7 @@
#include "playermgr.h"
#include "player.h"
#include "cs_proto.pb.h"
#include "ss_proto.pb.h"
#include "room.h"
#include "metamgr.h"
@ -25,6 +26,12 @@ void PlayerMgr::_SS_WSP_SocketDisconnect(f8::MsgHdr& hdr, const ss::SS_WSP_Socke
}
}
void PlayerMgr::_SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg)
{
ss::SS_Pong respmsg;
GGListener::Instance()->SendToClient(hdr.socket_handle, 0, respmsg);
}
int PlayerMgr::OnlineNum()
{
return socket_hash_.size();

View File

@ -8,6 +8,7 @@ namespace cs
namespace ss
{
class SS_WSP_SocketDisconnect;
class SS_Ping;
}
class Player;
@ -25,6 +26,7 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
void UnInit();
void _SS_WSP_SocketDisconnect(f8::MsgHdr& hdr, const ss::SS_WSP_SocketDisconnect& msg);
void _SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg);
int OnlineNum();
Player* GetPlayerBySocket(int socket);

@ -1 +1 @@
Subproject commit 9a8d93e085ee2ce420010501c2a1397aece62269
Subproject commit cdb87a3e673aee3401b3e2ffce3ea1a1e6a603b0

@ -1 +1 @@
Subproject commit b9f2f205afe3226fa06b6a3b9e62fcd6eaca63b8
Subproject commit 240414570ee2848291d24ff8d3102dc43d4104a3

@ -1 +1 @@
Subproject commit 9bc053e936b590f38621a6ef7b77155558c9a415
Subproject commit eb455bb95f97dc506566c443be0c72960ceebabf

2
third_party/tools vendored

@ -1 +1 @@
Subproject commit 093cc5830086f8a5a69e8792f8d0f16af496233c
Subproject commit b44f1b9c11a0bdf2711a8764343b37b5acb111cb