mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 03:32:33 +08:00
feat(main.py): 将配置加载流程放到start函数
This commit is contained in:
parent
419354cb07
commit
d1dff6dedd
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
config.py
|
||||
/config.py
|
||||
.idea/
|
||||
__pycache__/
|
||||
database.db
|
||||
|
|
|
@ -322,19 +322,6 @@ retry_times = 3
|
|||
# 设置为False时,向用户及管理员发送错误详细信息
|
||||
hide_exce_info_to_user = False
|
||||
|
||||
# 线程池相关配置
|
||||
# 该参数决定机器人可以同时处理几个人的消息,超出线程池数量的请求会被阻塞,不会被丢弃
|
||||
# 如果你不清楚该参数的意义,请不要更改
|
||||
# 程序运行本身线程池,无代码层面修改请勿更改
|
||||
sys_pool_num = 8
|
||||
|
||||
# 执行管理员请求和指令的线程池并行线程数量,一般和管理员数量相等
|
||||
admin_pool_num = 4
|
||||
|
||||
# 执行用户请求和指令的线程池并行线程数量
|
||||
# 如需要更高的并发,可以增大该值
|
||||
user_pool_num = 8
|
||||
|
||||
# 每个会话的过期时间,单位为秒
|
||||
# 默认值20分钟
|
||||
session_expire_time = 1200
|
||||
|
|
19
main.py
19
main.py
|
@ -171,6 +171,12 @@ def start(first_time_init=False):
|
|||
global known_exception_caught
|
||||
import pkg.utils.context
|
||||
|
||||
# 加载配置
|
||||
load_config()
|
||||
|
||||
# 检查tips模块
|
||||
complete_tips()
|
||||
|
||||
config = pkg.utils.context.get_config()
|
||||
# 更新openai库到最新版本
|
||||
if not hasattr(config, 'upgrade_dependencies') or config.upgrade_dependencies:
|
||||
|
@ -420,19 +426,12 @@ def main():
|
|||
init_runtime_log_file()
|
||||
pkg.utils.context.context['logger_handler'] = reset_logging()
|
||||
|
||||
# 加载配置
|
||||
load_config()
|
||||
config = pkg.utils.context.get_config()
|
||||
|
||||
# 检查tips模块
|
||||
complete_tips()
|
||||
|
||||
# 配置线程池
|
||||
from pkg.utils import ThreadCtl
|
||||
thread_ctl = ThreadCtl(
|
||||
sys_pool_num=config.sys_pool_num,
|
||||
admin_pool_num=config.admin_pool_num,
|
||||
user_pool_num=config.user_pool_num
|
||||
sys_pool_num=8,
|
||||
admin_pool_num=4,
|
||||
user_pool_num=8
|
||||
)
|
||||
# 存进上下文
|
||||
pkg.utils.context.set_thread_ctl(thread_ctl)
|
||||
|
|
|
@ -52,11 +52,10 @@ def reload_all(notify=True):
|
|||
|
||||
# 执行启动流程
|
||||
logging.info("执行程序启动流程")
|
||||
main.load_config()
|
||||
main.complete_tips()
|
||||
|
||||
context.get_thread_ctl().reload(
|
||||
admin_pool_num=context.get_config().admin_pool_num,
|
||||
user_pool_num=context.get_config().user_pool_num
|
||||
admin_pool_num=4,
|
||||
user_pool_num=8
|
||||
)
|
||||
context.get_thread_ctl().submit_sys_task(
|
||||
main.start,
|
||||
|
|
Loading…
Reference in New Issue
Block a user