mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-13 06:00:58 +00:00
fix: 重载时重复调用load_config()
This commit is contained in:
@@ -102,6 +102,7 @@ def reset_logging():
|
|||||||
pkg.utils.context.context['logger_handler'] = sh
|
pkg.utils.context.context['logger_handler'] = sh
|
||||||
return sh
|
return sh
|
||||||
|
|
||||||
|
|
||||||
# 临时函数,用于加载config和上下文,未来统一放在config类
|
# 临时函数,用于加载config和上下文,未来统一放在config类
|
||||||
def load_config():
|
def load_config():
|
||||||
# 完整性校验
|
# 完整性校验
|
||||||
@@ -121,13 +122,13 @@ def load_config():
|
|||||||
# 存进上下文
|
# 存进上下文
|
||||||
pkg.utils.context.set_config(config)
|
pkg.utils.context.set_config(config)
|
||||||
|
|
||||||
|
|
||||||
def start(first_time_init=False):
|
def start(first_time_init=False):
|
||||||
"""启动流程,reload之后会被执行"""
|
"""启动流程,reload之后会被执行"""
|
||||||
|
|
||||||
global known_exception_caught
|
global known_exception_caught
|
||||||
import pkg.utils.context
|
import pkg.utils.context
|
||||||
|
|
||||||
load_config() #暂时在start里加载config应对重载,未来在config抽象类中统一处理reload(未来删除该行)
|
|
||||||
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:
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ def reload_all(notify=True):
|
|||||||
context.context['exceeded_keys'] = context.get_openai_manager().key_mgr.exceeded
|
context.context['exceeded_keys'] = context.get_openai_manager().key_mgr.exceeded
|
||||||
this_context = context.context
|
this_context = context.context
|
||||||
walk(pkg)
|
walk(pkg)
|
||||||
|
importlib.reload(__import__("config-template"))
|
||||||
importlib.reload(__import__('config'))
|
importlib.reload(__import__('config'))
|
||||||
importlib.reload(__import__('main'))
|
importlib.reload(__import__('main'))
|
||||||
importlib.reload(__import__('banlist'))
|
importlib.reload(__import__('banlist'))
|
||||||
@@ -43,6 +44,7 @@ def reload_all(notify=True):
|
|||||||
|
|
||||||
# 执行启动流程
|
# 执行启动流程
|
||||||
logging.info("执行程序启动流程")
|
logging.info("执行程序启动流程")
|
||||||
|
main.load_config()
|
||||||
context.get_thread_ctl().reload(
|
context.get_thread_ctl().reload(
|
||||||
admin_pool_num=context.get_config().admin_pool_num,
|
admin_pool_num=context.get_config().admin_pool_num,
|
||||||
user_pool_num=context.get_config().user_pool_num
|
user_pool_num=context.get_config().user_pool_num
|
||||||
|
|||||||
Reference in New Issue
Block a user