This commit is contained in:
aozhiwei 2019-11-28 14:01:12 +08:00
parent 4606e07550
commit fc41c2e8e3
5 changed files with 16 additions and 15 deletions

View File

@ -1,9 +1,9 @@
cd third_party/wsproxy/server/wsproxy
python ../tools/scripts/construct/build_pb.py --nohooks 1
cmake $1 .
cmake -DGAME_ID=2002 -DMASTER_MODE=1 .
make clean
make
cp ../bin/wsproxy ../../../../bin/
cp ../bin/wsproxy ../../../../bin/wsproxy${GAME_ID}
cd ../../../../

View File

@ -28,16 +28,16 @@ def getExePath(pid):
def getExeCmdLine(pid):
return os.popen('cat /proc/%d/cmdline' % int(pid)).read()
def stop(instance_id):
def stop(instance_id, node_id):
wsproxy_ids = getRuningProgramPids('wsproxy')
pids = wsproxy_ids
for pid in pids:
exepath = getExePath(pid)
cmdline = getExeCmdLine(pid)
if cmdline == ("./wsproxy\0-i\0%d\0" % instance_id):
if cmdline == ("./wsproxy\0-i\0%d\0-n\0%d\0" % (instance_id, node_id)):
os.popen('kill -9 %d' % int(pid))
def listserver():
def listServer():
wsproxy_ids = getRuningProgramPids('wsproxy')
pids = wsproxy_ids
for pid in pids:
@ -45,30 +45,31 @@ def listserver():
cmdline = getExeCmdLine(pid)
print(pid, exepath, cmdline)
def restartServer(str_instance_ids):
def restartServer(str_instance_ids, str_node_id):
instance_ids = str_instance_ids.split(',')
node_id = int(str_node_id)
for instance_id in instance_ids:
instance_id = int(instance_id)
stop(instance_id)
stop(instance_id, node_id)
time.sleep(0.5)
print('wsproxy %d starting......' % instance_id)
cmd = 'sh start_instance.sh %d' % (instance_id)
cmd = 'sh start_instance.sh %d %d' % (instance_id, node_id)
os.popen(cmd)
time.sleep(0.5)
def printHelp():
print('usuage: [restart]')
print('usuage: [restart stop list]')
def main(argv):
if len(argv) == 1:
printHelp()
else:
if argv[1] == 'restart':
restartServer(argv[2])
restartServer(argv[2], argv[3])
elif argv[1] == 'stop':
stop()
stop(argv[2], argv[3])
elif argv[1] == 'list':
listserver()
listServer()
if __name__ == '__main__':
main(sys.argv)

View File

@ -1,5 +1,5 @@
#!/bin/bash
python manage.py restart $1
python manage.py restart $1 $2
echo 'success'

View File

@ -1,4 +1,4 @@
#!/bin/bash
cd bin
nohup ./wsproxy -i $1 >> wsproxy$1.out 2>&1 &
nohup ./$3 -i $1 -n $2 >> $3$2_$1.out 2>&1 &

View File

@ -58,7 +58,7 @@ def restartServer(str_instance_ids, str_node_id):
time.sleep(0.5)
def printHelp():
print('usuage: [restart]')
print('usuage: [restart stop list]')
def main(argv):
if len(argv) == 1: