diff --git a/.dockerignore b/.dockerignore index ab6ea41..a9a6e8b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,5 +17,5 @@ README.md # runtime data data/* -!data/config.ini +!data/config.example.ini log/* diff --git a/config.py b/config.py index 791dc67..962339f 100644 --- a/config.py +++ b/config.py @@ -7,7 +7,10 @@ from typing import * logger = logging.getLogger(__name__) -CONFIG_PATH = os.path.join('data', 'config.ini') +CONFIG_PATH_LIST = [ + os.path.join('data', 'config.ini'), + os.path.join('data', 'config.example.ini') +] _config: Optional['AppConfig'] = None @@ -21,8 +24,16 @@ def init(): def reload(): + config_path = '' + for path in CONFIG_PATH_LIST: + if os.path.exists(path): + config_path = path + break + if config_path == '': + return False + config = AppConfig() - if not config.load(CONFIG_PATH): + if not config.load(config_path): return False global _config _config = config diff --git a/data/config.ini b/data/config.example.ini similarity index 95% rename from data/config.ini rename to data/config.example.ini index 7571041..770700a 100644 --- a/data/config.ini +++ b/data/config.example.ini @@ -1,3 +1,6 @@ +# 如果要修改配置,可以复制此文件并重命名为“config.ini”再修改 +# If you want to modify the configuration, copy this file and rename it to "config.ini" and edit + [app] # 数据库配置,见https://docs.sqlalchemy.org/en/13/core/engines.html#database-urls # See https://docs.sqlalchemy.org/en/13/core/engines.html#database-urls