mirror of
https://github.com/zhayujie/bot-on-anything.git
synced 2026-01-19 09:41:07 +08:00
将终端通道放到主进程启动
This commit is contained in:
12
app.py
12
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()
|
||||
|
||||
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user