From 84a04012937281f1f1670667e15e96aba4fe52a9 Mon Sep 17 00:00:00 2001 From: H Vs Date: Wed, 16 Apr 2025 18:02:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 6 ++++-- celery_config.py | 5 ++++- config-dev.json | 3 ++- config-production.json | 3 ++- config-test.json | 3 ++- config.json | 3 ++- config.py | 3 ++- services/gewe_service.py | 16 +--------------- 8 files changed, 19 insertions(+), 23 deletions(-) diff --git a/app/main.py b/app/main.py index df3d4a8..3258f7d 100644 --- a/app/main.py +++ b/app/main.py @@ -142,6 +142,8 @@ async def lifespan(app: FastAPI): redis_port=conf().get("redis_port") redis_password=conf().get("redis_password") redis_db=conf().get("redis_db") + + wx_chat_api=conf().get("wx_chat_api") await redis_service.init(host=redis_host,port=redis_port, password=redis_password, db=redis_db) app.state.redis_service = redis_service @@ -154,7 +156,7 @@ async def lifespan(app: FastAPI): # 初始化 GeWeChatCom #app.state.gewe_service = await GeWeService.get_instance(redis_service,"http://api.geweapi.com/gewe") - app.state.gewe_service = await GeWeService.get_instance(redis_service,"http://218.78.116.24:10883/gewe") + app.state.gewe_service = await GeWeService.get_instance(redis_service,wx_chat_api) gewe_service=app.state.gewe_service # # 初始化 GeWeChatCom #app.state.gwechat_service = GeWeService(app) @@ -184,7 +186,7 @@ async def lifespan(app: FastAPI): 'group_id': KAFKA_GROUP_ID, } gewe_config = { - 'api_url': "http://api.geweapi.com/gewe", + 'api_url': wx_chat_api, } # Use Celery task diff --git a/celery_config.py b/celery_config.py index 6424299..8e0cfa3 100644 --- a/celery_config.py +++ b/celery_config.py @@ -18,6 +18,9 @@ redis_password=conf().get("redis_password") redis_db=conf().get("redis_db") encoded_password = quote(redis_password) + +wx_chat_api=conf().get("wx_chat_api") + # 配置 Celery celery_app = Celery( "worker", @@ -53,7 +56,7 @@ kafka_config = { } gewe_config = { #'api_url': "http://api.geweapi.com/gewe", - 'api_url':"http://218.78.116.24:10883/gewe", + 'api_url':wx_chat_api, } diff --git a/config-dev.json b/config-dev.json index d5a45ad..6dfa243 100644 --- a/config-dev.json +++ b/config-dev.json @@ -5,5 +5,6 @@ "redis_password":"telpo#1234", "redis_db":3, "kafka_bootstrap_servers":"192.168.2.121:9092", - "aiops_api":"https://id.ssjlai.com/aiopsadmin" + "aiops_api":"https://id.ssjlai.com/aiopsadmin", + "wx_chat_api":"http://api.geweapi.com/gewe" } diff --git a/config-production.json b/config-production.json index a6b5ec5..0b8a548 100644 --- a/config-production.json +++ b/config-production.json @@ -5,5 +5,6 @@ "redis_password":"telpo#1234", "redis_db":3, "kafka_bootstrap_servers":"172.19.42.40:9092,172.19.42.41:9092,172.19.42.48:9092", - "aiops_api":"https://ai.ssjlai.com/aiopsadmin" + "aiops_api":"https://ai.ssjlai.com/aiopsadmin", + "wx_chat_api":"http://api.geweapi.com/gewe" } diff --git a/config-test.json b/config-test.json index 153f956..8294f6b 100644 --- a/config-test.json +++ b/config-test.json @@ -5,5 +5,6 @@ "redis_password":"telpo#1234", "redis_db":3, "kafka_bootstrap_servers":"172.19.42.53:9092", - "aiops_api":"https://id.ssjlai.com/aiopsadmin" + "aiops_api":"https://id.ssjlai.com/aiopsadmin", + "wx_chat_api":"http://218.78.116.24:10883/gewe" } diff --git a/config.json b/config.json index d5a45ad..0f961cf 100644 --- a/config.json +++ b/config.json @@ -5,5 +5,6 @@ "redis_password":"telpo#1234", "redis_db":3, "kafka_bootstrap_servers":"192.168.2.121:9092", - "aiops_api":"https://id.ssjlai.com/aiopsadmin" + "aiops_api":"https://id.ssjlai.com/aiopsadmin", + "wx_chat_api":"http://218.78.116.24:10883/gewe" } diff --git a/config.py b/config.py index b3d906c..5bb348f 100644 --- a/config.py +++ b/config.py @@ -25,7 +25,8 @@ available_setting = { # kafka配置 "kafka_bootstrap_servers":"", # aiops平台 - "aiops_api":"" + "aiops_api":"", + "wx_chat_api":"" } class Config(dict): diff --git a/services/gewe_service.py b/services/gewe_service.py index e9ebe20..a4e7ba4 100644 --- a/services/gewe_service.py +++ b/services/gewe_service.py @@ -41,21 +41,7 @@ class GeWeService: cls._instance = cls(app,base_url) return cls._instance - # _instance = None - # def __new__(cls,app:FastAPI,base_url="http://api.geweapi.com/gewe"): - # if not cls._instance: - # cls._instance = super(GeWeService, cls).__new__(cls) - # cls._instance.client = None - # cls._instance.lock_renewal_thread = None - # return cls._instance - - # def __init__(self,app:FastAPI,base_url="http://api.geweapi.com/gewe"): - # if not hasattr(self, 'initialized'): - # #self.kafka_service =kafka_service # 获取 KafkaService 单例 - # # self.kafka_service =app.state.kafka_service - # self.redis_service=app.state.redis_service - # self.base_url = base_url - # self.initialized = True + ############################### 登录模块 ############################### async def check_login_async(self, token_id: str, app_id: str, uuid: str, captch_code: str = ""):