From bbffa4658182d3f958710cd59329057f2dda8ea9 Mon Sep 17 00:00:00 2001 From: youhuo Date: Wed, 17 Aug 2022 16:10:44 +0800 Subject: [PATCH] fix: docker config --- app.properties | 13 +++++-------- app/__init__.py | 2 +- app/conf.py | 24 ++++-------------------- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/app.properties b/app.properties index 2002253..0498fff 100644 --- a/app.properties +++ b/app.properties @@ -7,7 +7,7 @@ workers = 1 sanic_key = test-library auto_reload = False jwt_secret_key = test-lib-jwt-secret-key -main_domain = http://testlib-service.tone:8005/ +main_domain = http://testlib:8005/ # log log_mode = False @@ -17,23 +17,20 @@ formatter = %(asctime)s [%(process)d] [%(levelname)s] %(message)s formatter_access = %(asctime)s [%(process)d] [%(levelname)s] [%(host)s]: %(request)s %(message)s %(status)d %(byte)d # daily -db_url = mysql+aiomysql://xxxx/testlib +db_url = mysql+aiomysql://root:123456@127.0.0.1:3306/test-lib drop_all = False -create_all = False +create_all = True pool_size = 10 over_size = 10 recycle = 3600 # redis -redis_url = redis://xxxxx/41 +redis_url = redis://:123456@127.0.0.1:6379/10 # tone prod -tone_host = http://tone-service.tone:7001/ +tone_host = http://tone:7001/ tone_token = xxxx tone_user_name = xxxxx -tone_workspace = common_workspace -tone_project = 3 -tone_func_job = ???? # oss alg_oss_access_key = xxxxxx diff --git a/app/__init__.py b/app/__init__.py index f4f8e0f..ebc8017 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -8,7 +8,7 @@ from app.redis import redis def init_app(): app = Sanic('testlib') - conf.init_app(app, group='tone') + conf.init_app(app) log.init_app(app) db.init_app(app) redis.init_app(app) diff --git a/app/conf.py b/app/conf.py index b00cf31..40f01b0 100644 --- a/app/conf.py +++ b/app/conf.py @@ -11,25 +11,14 @@ class SanicConf(object): def init_app(self, app, env=None, group=None): self.config = None - if env is None: - env = os.environ.get('ENV', 'local') - if env == 'local': - file_name = 'app.properties' - from_nacos = False - else: - file_name = app.name + '.properties' - from_nacos = True - data = self.get_conf(env, file_name, from_nacos, group=group if group else app.name) + data = self.get_conf('app.properties') app.config.update(data) app.config.update(os.environ) self.config = app.config - def get_conf(self, env, file_name, from_nacos=False, group=None): - if from_nacos: - conf = self.nacos_client(env).get_config(data_id=file_name, group=group) - else: - with open(file_name, 'r', encoding='utf-8') as f: - conf = f.read() + def get_conf(self, file_name): + with open(file_name, 'r', encoding='utf-8') as f: + conf = f.read() lines = conf.splitlines() lines.extend(sys.argv) lines.append(f'pid={os.getpid()}') @@ -46,11 +35,6 @@ class SanicConf(object): conf_dict[key.upper()] = self.string_to_other(value) return conf_dict - def nacos_client(self, env): - nacos_client = None - nacos_client = nacos.NacosClient("server_address", "namespace", "ak","sk") - return nacos_client - def string_to_other(self, data): try: return int(data) -- Gitee