diff --git a/app.py b/app.py index 236d246..573d078 100644 --- a/app.py +++ b/app.py @@ -8,17 +8,17 @@ from multiprocessing import Pool # 启动通道 -def start_process(channel_type): - # 若为多进程启动,子进程无法直接访问主进程的内存空间,重新创建config类 - config.load_config(args.config) - model_type = config.conf().get("model").get("type") - log.info("[INIT] Start up: {} on {}", model_type, channel_type) +def start_process(channel_type, config_path): + try: + # 若为多进程启动,子进程无法直接访问主进程的内存空间,重新创建config类 + config.load_config(config_path) + model_type = config.conf().get("model").get("type") + log.info("[MultiChannel] Start up {} on {}", model_type, channel_type) + channel = channel_factory.create_channel(channel_type) + channel.startup() + except Exception as e: + log.error("[MultiChannel] Start up failed on {}: {}", channel_type, str(e)) - # create channel - channel = channel_factory.create_channel(channel_type) - - # startup channel - channel.startup() def main(): try: @@ -50,10 +50,10 @@ def main(): pool = Pool(len(channel_type)) for type_item in channel_type: log.info("[INIT] Start up: {} on {}", model_type, type_item) - pool.apply_async(start_process, args=[type_item]) + pool.apply_async(start_process, args=[type_item, args.config]) if terminal: - start_process(terminal) + start_process(terminal, args.config) # 等待池中所有进程执行完毕 pool.close()