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