1
This commit is contained in:
parent
f319442255
commit
f291af8a65
@ -28,31 +28,31 @@ def getExePath(pid):
|
|||||||
def getExeCmdLine(pid):
|
def getExeCmdLine(pid):
|
||||||
return os.popen('cat /proc/%d/cmdline' % int(pid)).read()
|
return os.popen('cat /proc/%d/cmdline' % int(pid)).read()
|
||||||
|
|
||||||
def stop(instance_id, node_id):
|
def stop(instance_id, node_id, progname):
|
||||||
wsproxy_ids = getRuningProgramPids('wsproxy')
|
wsproxy_ids = getRuningProgramPids(progname)
|
||||||
pids = wsproxy_ids
|
pids = wsproxy_ids
|
||||||
for pid in pids:
|
for pid in pids:
|
||||||
exepath = getExePath(pid)
|
exepath = getExePath(pid)
|
||||||
cmdline = getExeCmdLine(pid)
|
cmdline = getExeCmdLine(pid)
|
||||||
if cmdline == ("./wsproxy\0-i\0%d\0-n\0%d\0" % (instance_id, node_id)):
|
if cmdline == ("./%s\0-i\0%d\0-n\0%d\0" % (progname, instance_id, node_id)):
|
||||||
os.popen('kill -9 %d' % int(pid))
|
os.popen('kill -9 %d' % int(pid))
|
||||||
|
|
||||||
def listServer():
|
def listServer(progname):
|
||||||
wsproxy_ids = getRuningProgramPids('wsproxy')
|
wsproxy_ids = getRuningProgramPids(progname)
|
||||||
pids = wsproxy_ids
|
pids = wsproxy_ids
|
||||||
for pid in pids:
|
for pid in pids:
|
||||||
exepath = getExePath(pid)
|
exepath = getExePath(pid)
|
||||||
cmdline = getExeCmdLine(pid)
|
cmdline = getExeCmdLine(pid)
|
||||||
print(pid, exepath, cmdline)
|
print(pid, exepath, cmdline)
|
||||||
|
|
||||||
def restartServer(str_instance_ids, str_node_id):
|
def restartServer(str_instance_ids, str_node_id, progname):
|
||||||
instance_ids = str_instance_ids.split(',')
|
instance_ids = str_instance_ids.split(',')
|
||||||
node_id = int(str_node_id)
|
node_id = int(str_node_id)
|
||||||
for instance_id in instance_ids:
|
for instance_id in instance_ids:
|
||||||
instance_id = int(instance_id)
|
instance_id = int(instance_id)
|
||||||
stop(instance_id, node_id)
|
stop(instance_id, node_id, progname)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
print('wsproxy %d starting......' % instance_id)
|
print('%s %d %d starting......' % (progname, instance_id, node_id))
|
||||||
cmd = 'sh start_instance.sh %d %d' % (instance_id, node_id)
|
cmd = 'sh start_instance.sh %d %d' % (instance_id, node_id)
|
||||||
os.popen(cmd)
|
os.popen(cmd)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
@ -65,11 +65,11 @@ def main(argv):
|
|||||||
printHelp()
|
printHelp()
|
||||||
else:
|
else:
|
||||||
if argv[1] == 'restart':
|
if argv[1] == 'restart':
|
||||||
restartServer(argv[2], argv[3])
|
restartServer(argv[2], argv[3], argv[4])
|
||||||
elif argv[1] == 'stop':
|
elif argv[1] == 'stop':
|
||||||
stop(argv[2], argv[3])
|
stop(argv[2], argv[3], argv[4])
|
||||||
elif argv[1] == 'list':
|
elif argv[1] == 'list':
|
||||||
listServer()
|
listServer(argv[1])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user