fix(log): add support for CONFIG_DIR through environment variables

This commit is contained in:
InfinityPacer
2024-09-11 22:44:35 +08:00
parent 186476ad31
commit 8b336cf3eb
2 changed files with 14 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import re
import shutil
import sys
from pathlib import Path
from typing import List, Union, Tuple
from typing import List, Union, Tuple, Optional
import docker
import psutil
@@ -473,10 +473,14 @@ class SystemUtils:
return os.stat(src).st_dev == os.stat(dest).st_dev
@staticmethod
def get_config_path() -> Path:
def get_config_path(config_dir: Optional[str] = None) -> Path:
"""
获取配置路径
"""
if not config_dir:
config_dir = os.getenv("CONFIG_DIR")
if config_dir:
return Path(config_dir)
if SystemUtils.is_docker():
return Path("/config")
elif SystemUtils.is_frozen():