1
This commit is contained in:
parent
d7555020b9
commit
57fe3fe6de
34
server/bin/monitor_masterserver.py
Normal file
34
server/bin/monitor_masterserver.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
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_ms(gameid):
|
||||||
|
gameid = gameid.strip();
|
||||||
|
if gameid== '':
|
||||||
|
return
|
||||||
|
while True:
|
||||||
|
pids = getRuningProgramPids(f'masterserver{gameid}')
|
||||||
|
if len(pids) <= 0:
|
||||||
|
print('zzzz')
|
||||||
|
os.popen(f'nohup ./masterserver{gameid} -n1 -i1 -f1,2,4 >> masterserver{gameid}.out 2>&1 &')
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
monitor_ms(sys.argv[1])
|
@ -70,7 +70,7 @@ set(EXECUTABLE_OUTPUT_PATH
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
masterserver ${SRC_LIST}
|
masterserver${GAME_ID} ${SRC_LIST}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(script_pb_protocol ALL)
|
add_custom_target(script_pb_protocol ALL)
|
||||||
@ -78,12 +78,12 @@ add_custom_command(TARGET script_pb_protocol
|
|||||||
PRE_BUILD
|
PRE_BUILD
|
||||||
COMMAND python ../../third_party/tools/scripts/construct/build_pb.py --cpp_out=. --pb_files=ss_proto,ss_msgid --nohooks 1
|
COMMAND python ../../third_party/tools/scripts/construct/build_pb.py --cpp_out=. --pb_files=ss_proto,ss_msgid --nohooks 1
|
||||||
)
|
)
|
||||||
add_dependencies(masterserver script_pb_protocol)
|
add_dependencies(masterserver${GAME_ID} script_pb_protocol)
|
||||||
|
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
masterserver
|
masterserver${GAME_ID}
|
||||||
pthread
|
pthread
|
||||||
mysqlclient
|
mysqlclient
|
||||||
protobuf
|
protobuf
|
||||||
@ -101,7 +101,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
masterserver
|
masterserver${GAME_ID}
|
||||||
pthread
|
pthread
|
||||||
mysqlclient
|
mysqlclient
|
||||||
protobuf
|
protobuf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user