1
This commit is contained in:
parent
ff53825f43
commit
39b00edbe1
@ -1,35 +0,0 @@
|
|||||||
# -*- 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_app(exename, args):
|
|
||||||
exename = exename.strip();
|
|
||||||
if exename == '':
|
|
||||||
return
|
|
||||||
args = args.strip()
|
|
||||||
while True:
|
|
||||||
pids = getRuningProgramPids(f'{exename}')
|
|
||||||
if len(pids) <= 0:
|
|
||||||
print('zzzz')
|
|
||||||
os.popen(f'nohup ./{exename} {args} >> {exename}.out 2>&1 &')
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
monitor_app(sys.argv[1], sys.argv[2])
|
|
Loading…
x
Reference in New Issue
Block a user