Fix config path, env secrets, and align API calls
This commit is contained in:
@@ -4,7 +4,26 @@ import os
|
||||
import mysql.connector
|
||||
from util.logger import logger
|
||||
|
||||
CONFIG_PATH = "./config/db_config.json"
|
||||
|
||||
def _resolve_config_path() -> str:
|
||||
"""
|
||||
Prefer an explicit env override, otherwise use a docker-friendly default
|
||||
(/config) and fall back to the repo-local config folder for non-docker dev.
|
||||
"""
|
||||
if env_path := os.environ.get("DB_CONFIG_PATH"):
|
||||
return os.path.abspath(env_path)
|
||||
|
||||
docker_path = "/config/db_config.json"
|
||||
if os.path.exists("/config"):
|
||||
return docker_path
|
||||
|
||||
# local fallback: backend/config/db_config.json (relative to this file)
|
||||
return os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), "..", "config", "db_config.json")
|
||||
)
|
||||
|
||||
|
||||
CONFIG_PATH = _resolve_config_path()
|
||||
|
||||
def is_configured():
|
||||
return os.path.exists(CONFIG_PATH)
|
||||
|
||||
Reference in New Issue
Block a user