Cache song

This commit is contained in:
A-random-githuber
2025-12-26 00:33:28 +07:00
committed by GitHub
parent 707f881bdb
commit 73f28f38d3

View File

@@ -1,5 +1,6 @@
# encoding: utf-8
import json
import os
from importlib import import_module
@@ -7,7 +8,14 @@ from core.config_manager import Config, ConfigManager
if os.path.exists('config.py') or os.path.exists('config'):
# 导入用户自定义配置
ConfigManager.load(import_module('config').Config)
ConfigManager.load(import_module("config").Config)
else:
# Allow importing the config from a custom path given through an environment variable
configPath = os.environ.get("ARCAEA_JSON_CONFIG_PATH")
if configPath and os.path.exists(configPath):
with open(configPath, 'r') as file:
ConfigManager.load_dict(json.load(file))
if Config.DEPLOY_MODE == 'gevent':
# 异步
@@ -17,7 +25,7 @@ if Config.DEPLOY_MODE == 'gevent':
import sys
from logging.config import dictConfig
from multiprocessing import Process, set_start_method
from multiprocessing import Process, current_process, set_start_method
from traceback import format_exc
from flask import Flask, make_response, request, send_from_directory
@@ -183,7 +191,7 @@ def pre_main():
'stream': 'ext://flask.logging.wsgi_errors_stream',
'formatter': 'default'
},
"error_file": generate_log_file_dict('ERROR', './log/error.log')
"error_file": generate_log_file_dict('ERROR', f'{Config.LOG_FOLDER_PATH}/error.log')
},
'formatters': {
'default': {
@@ -194,11 +202,11 @@ def pre_main():
if Config.ALLOW_INFO_LOG:
log_dict['root']['handlers'].append('info_file')
log_dict['handlers']['info_file'] = generate_log_file_dict(
'INFO', './log/info.log')
'INFO', f'{Config.LOG_FOLDER_PATH}/info.log')
if Config.ALLOW_WARNING_LOG:
log_dict['root']['handlers'].append('warning_file')
log_dict['handlers']['warning_file'] = generate_log_file_dict(
'WARNING', './log/warning.log')
'WARNING', f'{Config.LOG_FOLDER_PATH}/warning.log')
dictConfig(log_dict)
@@ -226,7 +234,9 @@ def main():
# must run for init
pre_main()
# this ensures avoiding duplicate init logs for some reason
if current_process().name == 'MainProcess':
pre_main()
if __name__ == '__main__':
set_start_method("spawn")