import Port import subprocess import time print("start memcached ...") prot = 11211 cmd = "D:/memcached.exe" if Port.isExist(prot): Port.kill(prot); time.sleep(3) proc = subprocess.Popen(cmd, shell=True) print("memcached ok !") print("start resin ...") prot = 8082 # cmd = "D:/pdlib-resin-3.0.14/httpd -Xmn256m -Xms512m -Xmx1024m -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001 -conf conf/resin-product.conf" cmd = "D:/pdlib-resin-3.0.14/httpd -Xmn256m -Xms512m -Xmx1024m -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001 -conf conf/resin-product-svn.conf" method = "httpd" maxFailTime = 60 if Port.isExist(prot): Port.kill(prot); time.sleep(3) proc = subprocess.Popen(cmd, shell=True) print("resin ok !")
#coding=GBK import subprocess import sys import Port def isExist(port): proc = subprocess.Popen("netstat -aon|findstr "+str(port), shell=True, stdout=subprocess.PIPE) out = str(proc.stdout.read()) index = out.find(":"+str(port)) if index == -1: return False else: return True if len(sys.argv)>1: if sys.argv[1].isdigit(): status = Port.kill(sys.argv[1]) print(status) else: print("parameters error!") else: print("No parameters!")
import Port import subprocess import threading import time prot = 81 cmd = "C:/command/resin-3.1.9/httpd" method = "httpd" maxFailTime = 60 def killForm(): k = maxFailTime while not Port.isExist(prot) and k > 0: time.sleep(1) k -= 1 Port.simplekillByName(prot, method) if Port.isExist(prot): Port.kill(prot); threading.Thread(target=killForm).start() proc = subprocess.Popen(cmd, shell=True)
import time import socket hostName = socket.gethostname() if hostName == 'lym' : prot = 83 cmd = "D:/resin-3.1.9/httpd -conf conf/struts1_core_test.conf" else: prot = 81 cmd = "C:/command/resin-3.1.9/httpd -conf conf/struts1_core_test.conf" method = "httpd" maxFailTime = 6000 def killForm(): k = maxFailTime while not Port.isExist(prot) and k > 0: time.sleep(1) k -= 1 if Port.isExist(prot): print("kill httpd.exe") Port.simplekillByName(prot, method) Port.simplekillByName(prot, method) Port.kill(prot) threading.Thread(target=killForm).start() proc = subprocess.Popen(cmd, shell=True)