def start_cfssl(cmdline=""):
global cfsslproc
cmd = "cfssl serve -loglevel=1 %s "%cmdline
env = os.environ.copy()
env['PATH']=env['PATH']+":/usr/local/bin"
# make sure cfssl isn't running
os.system('pkill -f cfssl')
cfsslproc = subprocess.Popen(cmd,env=env,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,universal_newlines=True)
if cfsslproc.returncode is not None:
raise Exception("Unable to launch %: failed with code "%(cmd,cfsslproc.returncode))
logger.debug("Waiting for cfssl to start...")
while True:
line = cfsslproc.stdout.readline()
if "Now listening on" in line:
break
time.sleep(0.2)# give cfssl a little more time to get started
logger.debug("cfssl started successfully")
评论列表
文章目录