将终端通道放到主进程启动

This commit is contained in:
RA
2023-03-19 00:45:46 +08:00
parent 033a29f6ea
commit d5944ceb4c
2 changed files with 11 additions and 3 deletions

12
app.py
View File

@@ -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()

View File

@@ -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"],