Просмотр исходного кода

[update] :heavy_check_mark: print config

jhao 6 лет назад
Родитель
Сommit
c114560000
3 измененных файлов с 14 добавлено и 8 удалено
  1. 11 3
      db/dbClient.py
  2. 2 2
      proxyPool.py
  3. 1 3
      setting.py

+ 11 - 3
db/dbClient.py

@@ -23,7 +23,7 @@ from util.singleton import Singleton
 sys.path.append(os.path.dirname(os.path.abspath(__file__)))
 
 
-class DbClient(object):
+class DbClient(metaclass=Singleton):
     """
     DbClient DB工厂类 提供get/put/update/pop/delete/exists/getAll/clean/getCount/changeTable方法
 
@@ -48,8 +48,6 @@ class DbClient(object):
 
     """
 
-    __metaclass__ = Singleton
-
     def __init__(self, db_conn):
         """
         init
@@ -57,6 +55,7 @@ class DbClient(object):
         """
         self.db_conn = db_conn
         self.parseDbConn(db_conn)
+        self.__printConfig()
         self.__initDbClient()
 
     @classmethod
@@ -91,6 +90,15 @@ class DbClient(object):
                                                                                      password=self.db_pwd,
                                                                                      db=self.db_name)
 
+    def __printConfig(self):
+        print("============ DATABASE CONFIGURE =========================")
+        print("DB_TYPE: %s" % self.db_type)
+        print("DB_HOST: %s" % self.db_host)
+        print("DB_PORT: %s" % self.db_port)
+        print("DB_NAME: %s" % self.db_name)
+        print("DB_USER: %s" % self.db_user)
+        print("=========================================================")
+
     def get(self, **kwargs):
         return self.client.get(**kwargs)
 

+ 2 - 2
proxyPool.py

@@ -15,8 +15,6 @@ __author__ = 'JHao'
 import click
 
 from setting import BANNER
-from helper.scheduler import runScheduler
-from api.proxyApi import runFlask
 
 CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
 
@@ -31,6 +29,7 @@ def cli():
 def schedule():
     """ 启动调度程序 """
     click.echo(BANNER)
+    from helper.scheduler import runScheduler
     runScheduler()
 
 
@@ -38,6 +37,7 @@ def schedule():
 def server():
     """ 启动api服务 """
     click.echo(BANNER)
+    from api.proxyApi import runFlask
     runFlask()
 
 

+ 1 - 3
setting.py

@@ -25,14 +25,12 @@ BANNER = r"""
 ****************************************************************
 """
 
-SHOW_CONFIG = True            # print config
-
 # ############### server config ###############
 HOST = "0.0.0.0"
 
 PORT = 5010
 
-# ############### db config ###################
+# ############### database config ###################
 # db connection uri
 # example:
 #      Redis: redis://:password@ip:port/db