|
@@ -83,7 +83,11 @@ mongodb = mcli[MONGO_DB]
|
|
|
ES_HOST = "172.17.145.178"
|
|
|
ES_PORT = 9200
|
|
|
ES_INDEX = "biddingall"
|
|
|
-ecli = Elasticsearch([{"host": ES_HOST, "port": ES_PORT}])
|
|
|
+try:
|
|
|
+ ecli = Elasticsearch([{"host": ES_HOST, "port": ES_PORT}])
|
|
|
+except ConnectionRefusedError as e:
|
|
|
+ logger.error(f"es服务拒绝访问,原因:{e}")
|
|
|
+ ecli = None
|
|
|
|
|
|
|
|
|
def err_msg(worker):
|
|
@@ -123,6 +127,8 @@ def es_query(title, publish_time):
|
|
|
:param publish_time: 发布时间
|
|
|
:return:
|
|
|
"""
|
|
|
+ if not ecli:
|
|
|
+ return 0 # 如果es检索服务异常,保证数据正常推送
|
|
|
publish_time = date2ts(publish_time)
|
|
|
stime = publish_time - 432000 # 往前推5天
|
|
|
etime = publish_time + 432000
|
|
@@ -144,7 +150,7 @@ def es_query(title, publish_time):
|
|
|
}
|
|
|
}
|
|
|
result = ecli.search(body=query, index=ES_INDEX, request_timeout=100)
|
|
|
- total = int(result["hits"]["total"]['value']) # es7.x版本(等待切换)
|
|
|
+ total = int(result["hits"]["total"]['value'])
|
|
|
return total
|
|
|
|
|
|
|