def init(conf_file, port=''): # 载入配置文件 os.chdir(os.path.join(os.path.dirname(__file__), '..')) confs = JsonConfiger.get_instance() confs.load_file(conf_file) # 初始化日志 log_cnf = confs.get('logging') if log_cnf['config_file'][:1] not in ['/', '\\']: log_cnf['config_file'] = os.path.join( os.path.dirname(os.path.abspath(conf_file)), log_cnf['config_file']) Log.set_up(log_cnf, port) global logger logger = Log().getLog() #各模块配置 db_pool.set_up(confs.get("database")) sms.set_up(confs.get("aliyun")) # 初始化消息总线 #xmsgbus.set_up(confs) #db_pool.set_up_cache(confs.get("sys_config")) gen_verify_code.set_up(confs.get("files")) jiuzhao.set_up(confs.get("jiuzhao")) lianlian.set_up(confs.get("lianlian")) rmq.setup_producer(confs.get("mq/rabbitmq")) # 加载业务代码 import hooks ews.load_biz_dir(path._BIZ_PATH)
def init_application(conf_file): """初始化应用程序 """ os.chdir(os.path.join(os.path.dirname(__file__), '..')) confs = JsonConfiger.get_instance() confs.load_file(conf_file) log_cnf = confs.get('logging') if log_cnf['config_file'][:1] not in ['/', '\\']: log_cnf['config_file'] = os.path.join( os.path.dirname(os.path.abspath(conf_file)), log_cnf['config_file']) Log.set_up(log_cnf) global logger logger = Log().getLog() util.route.set_up(path._BIZ_PATH) return confs
def init(conf_file): # 载入配置文件 os.chdir(os.path.join(os.path.dirname(__file__), '..')) confs = JsonConfiger.get_instance() confs.load_file(conf_file) # 初始化日志 log_cnf = confs.get('logging') if log_cnf['config_file'][:1] not in ['/', '\\']: log_cnf['config_file'] = os.path.join(os.path.dirname(os.path.abspath(conf_file)), log_cnf['config_file']) Log.set_up(log_cnf) global logger logger = Log().getLog() # 加载业务代码 ews.load_biz_dir(path._BIZ_PATH)
def init(conf_file, svr_type='', port=''): #载入配置文件 os.chdir(os.path.join(os.path.dirname(__file__), '..')) confs = JsonConfiger.get_instance() confs.load_file(conf_file) #初始化日志 log_cnf = confs.get('logging') if log_cnf['config_file'][:1] not in ['/', '\\']: log_cnf['config_file'] = os.path.join( os.path.dirname(os.path.abspath(conf_file)), log_cnf['config_file']) Log.set_up(log_cnf, port) global logger logger = Log().getLog() #初始化db db_pool.set_up(confs.get("database")) #初始化mq xmsgbus.set_up(confs) rmq.setup_producer(confs.get("mq/rabbitmq"))
# coding: utf-8 import json import traceback import pika from util import pika_pool from util.tools import Log from util.configer import JsonConfiger logger = Log().getLog() # 配置初始化 config = {} # 生产者池 producer_pool = None # 注册消息处理回调 ROUTING_TO_BIND = [] callbacks = {} # 注册回调函数 def subscribe_callback_register(queue, routing_key=None): if not routing_key: routing_key = queue def decorator(func): if queue not in ROUTING_TO_BIND: ROUTING_TO_BIND.append({