fix(1panel): sync MySQL/Redis container hosts on nx update
Upgrade was skipping 1panel-network detection; wizard now overrides stale host.docker.internal from volume/API defaults. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+20
-2
@@ -33,6 +33,7 @@ ENV_FILE = ROOT_DIR / ".env"
|
||||
INSTALL_LOCK = ROOT_DIR / ".install_locked"
|
||||
CONFIG_DIR = ROOT_DIR / "web" / "data"
|
||||
CONFIG_JSON = CONFIG_DIR / "config.json"
|
||||
ONEPANEL_HOSTS_JSON = CONFIG_DIR / "1panel-hosts.json"
|
||||
STATE_FILE = ROOT_DIR / ".install_state.json"
|
||||
|
||||
|
||||
@@ -98,10 +99,27 @@ def _build_redis_url(req: InitDbRequest) -> str:
|
||||
return url
|
||||
|
||||
|
||||
def _read_1panel_hosts_file() -> dict[str, str]:
|
||||
if not ONEPANEL_HOSTS_JSON.is_file():
|
||||
return {}
|
||||
import json
|
||||
|
||||
try:
|
||||
raw = json.loads(read_utf8_text(ONEPANEL_HOSTS_JSON))
|
||||
except (json.JSONDecodeError, OSError):
|
||||
return {}
|
||||
if not isinstance(raw, dict):
|
||||
return {}
|
||||
return {str(k): str(v) for k, v in raw.items() if v}
|
||||
|
||||
|
||||
def _onepanel_service_host(kind: str) -> str | None:
|
||||
"""1Panel App Store container name (NEXUS_1PANEL_DB_HOST / REDIS_HOST)."""
|
||||
"""1Panel App Store container name (env → web/data/1panel-hosts.json)."""
|
||||
val = os.environ.get(f"NEXUS_1PANEL_{kind}_HOST", "").strip()
|
||||
return val or None
|
||||
if val:
|
||||
return val
|
||||
file_key = "db_host" if kind == "DB" else "redis_host"
|
||||
return _read_1panel_hosts_file().get(file_key) or None
|
||||
|
||||
|
||||
def _resolve_redis_probe() -> tuple[str, int, str | None]:
|
||||
|
||||
Reference in New Issue
Block a user