This commit is contained in:
aozhiwei 2019-12-16 19:02:03 +08:00
parent 2a8f61d29f
commit f1a02faa01

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('gameserver2001')
if len(pids) <= 0:
print('zzzz')
os.popen('nohup ./gameserver2001 -n1 -i1 -f1,2,4 >> gameserver2001.out 2>&1 &')
time.sleep(2)
monitor_gs()