修复杀进程问题

This commit is contained in:
aozhiwei 2019-08-31 17:38:24 +08:00
parent 15f8a6fdf9
commit 958a673379

View File

@ -28,7 +28,9 @@ def getExePath(pid):
def getExeCmdLine(pid):
return os.popen('cat /proc/%d/cmdline' % int(pid)).read()
def stop(instance_id, node_id):
def stop(instance_id, node_id, times = 0):
if times > 2:
return
gameserver_ids = getRuningProgramPids('gameserver')
pids = gameserver_ids
for pid in pids:
@ -36,6 +38,15 @@ def stop(instance_id, node_id):
cmdline = getExeCmdLine(pid)
if cmdline == ("./gameserver\0-i\0%d\0-n\0%d\0" % (instance_id, node_id)):
os.popen('kill -9 %d' % int(pid))
#endfor
gameserver_ids = getRuningProgramPids('gameserver')
pids = gameserver_ids
for pid in pids:
exepath = getExePath(pid)
cmdline = getExeCmdLine(pid)
if cmdline == ("./gameserver\0-i\0%d\0-n\0%d\0" % (instance_id, node_id)):
time.sleep(1)
stop(instance_id, node_id, times + 1)
def listServer():
gameserver_ids = getRuningProgramPids('gameserver')