Files
ComfyUI_Skills_OpenClaw/ui/settings.py
科林_Cyril Pilgrim 8a274ad02a refactor(core): simplify workflow identification and update default ui port
Motivation:
1. Maintaining a redundant 'workflow_id' in schema.json was error-prone and confusing for users.
2. The previous default port 8189 frequently collided with other AI services or ComfyUI instances during multi-server deployment.

Implementation:
1. Revoked 'workflow_id' reliance in schema logic; the system now strictly uses the directory name as the unique identifier.
2. Updated default web UI port to 18189 and added support for the 'OPENCLAW_UI_PORT' environment variable across scripts and settings.
3. Synchronized documentation and UI launcher scripts to reflect these changes.
2026-03-12 15:39:17 +08:00

51 lines
1.3 KiB
Python

from __future__ import annotations
import os
from pathlib import Path
from shared.config import (
DATA_DIR,
get_server_data_dir,
)
from shared.runtime_config import get_runtime_config
BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_DIR = BASE_DIR / "ui" / "static"
CONFIG_PATH = BASE_DIR / "config.json"
CONFIG_EXAMPLE_PATH = BASE_DIR / "config.example.json"
OUTPUTS_DIR = BASE_DIR / "outputs"
DEFAULT_HOST = "127.0.0.1"
def _read_default_port() -> int:
raw = os.environ.get("OPENCLAW_UI_PORT", "18189").strip()
try:
port = int(raw)
except ValueError:
return 18189
return port if 1 <= port <= 65535 else 18189
DEFAULT_PORT = _read_default_port()
DEFAULT_COMFYUI_SERVER_URL = "http://127.0.0.1:8188"
def ensure_runtime_dirs() -> None:
"""Create data directories for all configured servers."""
STATIC_DIR.mkdir(parents=True, exist_ok=True)
OUTPUTS_DIR.mkdir(parents=True, exist_ok=True)
config = get_runtime_config()
for server in config.get("servers", []):
server_id = server.get("id")
if server_id:
get_server_data_dir(server_id).mkdir(parents=True, exist_ok=True)
def default_config() -> dict[str, str]:
return {
"comfyui_server_url": DEFAULT_COMFYUI_SERVER_URL,
"output_dir": "./outputs",
}