提交 19199884 编写于 作者: C cpwu

fix assert taosadapter

上级 79cd8848
import socket
from fabric2 import Connection from fabric2 import Connection
from util.log import * from util.log import *
from util.common import * from util.common import *
...@@ -46,8 +47,28 @@ class TAdapter: ...@@ -46,8 +47,28 @@ class TAdapter:
"user" : "root", "user" : "root",
"password" : "taosdata", "password" : "taosdata",
"writeInterval" : "30s" "writeInterval" : "30s"
} },
"opentsdb" : {
"enable" : False
},
"influxdb" : {
"enable" : False
},
"statsd" : {
"enable" : False
},
"collectd" : {
"enable" : False
},
"opentsdb_telnet" : {
"enable" : False
},
"node_exporter" : {
"enable" : False
},
"prometheus" : {
"enable" : False
},
} }
# TODO: add taosadapter env: # TODO: add taosadapter env:
# 1. init cfg.toml.dict :OK # 1. init cfg.toml.dict :OK
...@@ -156,40 +177,20 @@ class TAdapter: ...@@ -156,40 +177,20 @@ class TAdapter:
tdLog.debug(f"taosadapter is running with {cmd} " ) tdLog.debug(f"taosadapter is running with {cmd} " )
time.sleep(0.1) time.sleep(0.1)
key = 'all plugin init finish'
bkey = bytes(key, encoding="utf8") taosadapter_port = self.taosadapter_cfg_dict["port"]
logFile = self.log_dir + "/taosadapter*" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
file_exists = False s.settimeout(3)
i = 0 try:
while (not file_exists): res = s.connect_ex((self.remoteIP, taosadapter_port))
for file in os.listdir(self.log_dir): if res == 0:
if "taosadapter" in file: tdLog.info(f"the taosadapter has been started, using port:{taosadapter_port}")
file_exists = True else:
break tdLog.info(f"the taosadapter do not started!!!")
sleep(0.1) except socket.error as e:
i += 1 tdLog.notice("socket connect error!")
if i > 50: # tdLog.debug("the taosadapter has been started.")
tdLog.notice("log file is too long to create") time.sleep(1)
break
tailCmdStr = 'tail -f '
popen = subprocess.Popen(
tailCmdStr + logFile,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
# pid = popen.pid
# print('Popen.pid:' + str(pid))
timeout = time.time() + 60 * 2
while True:
line = popen.stdout.readline().strip()
if bkey in line:
popen.kill()
break
if time.time() > timeout:
tdLog.exit('wait too long for taosadapter start')
tdLog.debug("the taosadapter has been started.")
time.sleep(2)
def start_taosadapter(self): def start_taosadapter(self):
""" """
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册