mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 11:42:44 +08:00
feat: 修改日志初始化顺序
This commit is contained in:
parent
d1549b3df0
commit
cf678aa345
29
main.py
29
main.py
|
@ -75,7 +75,7 @@ def init_runtime_log_file():
|
|||
def reset_logging():
|
||||
global log_file_name
|
||||
|
||||
config = pkg.utils.context.get_config()
|
||||
import config
|
||||
|
||||
if pkg.utils.context.context['logger_handler'] is not None:
|
||||
logging.getLogger().removeHandler(pkg.utils.context.context['logger_handler'])
|
||||
|
@ -124,10 +124,11 @@ def start(first_time_init=False):
|
|||
|
||||
known_exception_caught = False
|
||||
try:
|
||||
init_runtime_log_file()
|
||||
|
||||
sh = reset_logging()
|
||||
|
||||
pkg.utils.context.context['logger_handler'] = sh
|
||||
|
||||
# 检查是否设置了管理员
|
||||
if not (hasattr(config, 'admin_qq') and config.admin_qq != 0):
|
||||
# logging.warning("未设置管理员QQ,管理员权限指令及运行告警将无法使用,如需设置请修改config.py中的admin_qq字段")
|
||||
|
@ -160,7 +161,6 @@ def start(first_time_init=False):
|
|||
|
||||
pkg.openai.dprompt.read_prompt_from_file()
|
||||
|
||||
pkg.utils.context.context['logger_handler'] = sh
|
||||
# 主启动流程
|
||||
database = pkg.database.manager.DatabaseManager()
|
||||
|
||||
|
@ -296,13 +296,6 @@ def stop():
|
|||
|
||||
# 临时函数,用于加载config和上下文,未来统一放在config类
|
||||
def load_config():
|
||||
|
||||
# 存在性校验
|
||||
if not os.path.exists('config.py'):
|
||||
shutil.copy('config-template.py', 'config.py')
|
||||
print('请先在config.py中填写配置')
|
||||
sys.exit(0)
|
||||
|
||||
# 完整性校验
|
||||
is_integrity = True
|
||||
config_template = importlib.import_module('config-template')
|
||||
|
@ -322,6 +315,12 @@ def load_config():
|
|||
|
||||
|
||||
def check_file():
|
||||
# 配置文件存在性校验
|
||||
if not os.path.exists('config.py'):
|
||||
shutil.copy('config-template.py', 'config.py')
|
||||
print('请先在config.py中填写配置')
|
||||
sys.exit(0)
|
||||
|
||||
# 检查是否有banlist.py,如果没有就把banlist-template.py复制一份
|
||||
if not os.path.exists('banlist.py'):
|
||||
shutil.copy('banlist-template.py', 'banlist.py')
|
||||
|
@ -342,13 +341,17 @@ def check_file():
|
|||
|
||||
|
||||
def main():
|
||||
# 初始化相关文件
|
||||
check_file()
|
||||
|
||||
# 初始化logging
|
||||
init_runtime_log_file()
|
||||
pkg.utils.context.context['logger_handler'] = reset_logging()
|
||||
|
||||
# 加载配置
|
||||
load_config()
|
||||
config = pkg.utils.context.get_config()
|
||||
|
||||
# 初始化相关文件
|
||||
check_file()
|
||||
|
||||
# 配置线程池
|
||||
from pkg.utils import ThreadCtl
|
||||
thread_ctl = ThreadCtl(
|
||||
|
|
Loading…
Reference in New Issue
Block a user