add bin directory
This commit is contained in:
parent
f3d5c41778
commit
4d0b3effca
12
server/bin/compile.sh
Normal file
12
server/bin/compile.sh
Normal file
@ -0,0 +1,12 @@
|
||||
cd ../../
|
||||
if [ $# == 0 ]; then
|
||||
git checkout master
|
||||
else
|
||||
git checkout $1
|
||||
fi
|
||||
git pull
|
||||
git submodule init
|
||||
git submodule update
|
||||
cd server/gameserver
|
||||
cmake .
|
||||
make
|
5
server/bin/gmtool.sh
Executable file
5
server/bin/gmtool.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd ../tools/robot/virtualclient
|
||||
#python robot.py ws://192.168.100.21:7101 hao1069 hao1069 $1
|
||||
python robot.py "wss://game2001-test.kingsome.cn" hao1069 hao1069 $1
|
75
server/bin/manage.py
Executable file
75
server/bin/manage.py
Executable file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/python
|
||||
#coding utf8
|
||||
|
||||
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 getExePath(pid):
|
||||
return os.popen('ls -l /proc/%d | grep "exe ->" | cut -d " " -f 7-' % int(pid)).read()
|
||||
|
||||
def getExeCmdLine(pid):
|
||||
return os.popen('cat /proc/%d/cmdline' % int(pid)).read()
|
||||
|
||||
def stop(instance_id, node_id):
|
||||
gameserver_ids = getRuningProgramPids('gameserver')
|
||||
pids = gameserver_ids
|
||||
for pid in pids:
|
||||
exepath = getExePath(pid)
|
||||
cmdline = getExeCmdLine(pid)
|
||||
if cmdline.find(("./gameserver\0-i\0%d\0-n\0%d\0" % (instance_id, node_id))) > -1:
|
||||
os.popen('kill -9 %d' % int(pid))
|
||||
|
||||
def listServer():
|
||||
gameserver_ids = getRuningProgramPids('gameserver')
|
||||
pids = gameserver_ids
|
||||
for pid in pids:
|
||||
exepath = getExePath(pid)
|
||||
cmdline = getExeCmdLine(pid)
|
||||
print(pid, exepath, cmdline)
|
||||
|
||||
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, node_id)
|
||||
time.sleep(0.5)
|
||||
print('gameserver %d starting......' % 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]')
|
||||
|
||||
def main(argv):
|
||||
if len(argv) == 1:
|
||||
printHelp()
|
||||
else:
|
||||
if argv[1] == 'restart':
|
||||
restartServer(argv[2], argv[3])
|
||||
elif argv[1] == 'stop':
|
||||
stop(argv[2], argv[3])
|
||||
elif argv[1] == 'list':
|
||||
listServer()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
30
server/bin/monitor.py
Normal file
30
server/bin/monitor.py
Normal file
@ -0,0 +1,30 @@
|
||||
# -*- 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('gameserver2001')
|
||||
if len(pids) <= 0:
|
||||
print('zzzz')
|
||||
os.popen('nohup ./gameserver2001 -n1 -i1 >> gameserver2001.out 2>&1 &')
|
||||
time.sleep(2)
|
||||
|
||||
monitor_gs()
|
5
server/bin/restart.sh
Executable file
5
server/bin/restart.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
python manage.py restart $1 $2
|
||||
|
||||
echo 'success'
|
7
server/bin/start_instance.sh
Executable file
7
server/bin/start_instance.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /etc/profile
|
||||
source /root/.bash_profile
|
||||
|
||||
nohup ./gameserver -i $1 -n $2 -f1,2,3,4,6>> gameserver$2_$1.out 2>&1 &
|
||||
|
Loading…
x
Reference in New Issue
Block a user