diff --git a/app.py b/app.py index bd9ddba..bbfcbb5 100644 --- a/app.py +++ b/app.py @@ -24,13 +24,21 @@ if __name__ == '__main__': model_type = config.conf().get("model").get("type") channel_type = config.conf().get("channel").get("type") - # 使用进程池启动子进程 + # 使用主进程启动终端通道 + if "terminal" in channel_type: + index=channel_type.index("terminal") + terminal = channel_type.pop(index) + else: + terminal = None + # 使用进程池启动其他通道子进程 pool = Pool(len(channel_type)) - for type in channel_type: log.info("[INIT] Start up: {} on {}", model_type, type) pool.apply_async(wrapper, args=[type]) + if terminal: + channel = channel_factory.create_channel(terminal) + channel.startup() # 等待池中所有进程执行完毕 pool.close() pool.join() diff --git a/config-template.json b/config-template.json index b18714f..4ba4094 100644 --- a/config-template.json +++ b/config-template.json @@ -15,7 +15,7 @@ }, "channel": { - "type": ["http","wechat"], + "type": ["http","wechat","terminal"], "single_chat_prefix": ["bot", "@bot"], "single_chat_reply_prefix": "[bot] ", "group_chat_prefix": ["@bot"],