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