From 34786b37c71e073ef683bb1c148199b2e2ac45e9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 25 Mar 2026 16:59:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/config.yaml | 6 +++--- dev.sh | 8 +++++--- docker-compose.yml | 19 ++++++++----------- server/index.js | 28 ++++++++++++++++++++++------ server/public/index.html | 17 +++++++++++++++-- 5 files changed, 53 insertions(+), 25 deletions(-) diff --git a/configs/config.yaml b/configs/config.yaml index be2485d..11ab367 100644 --- a/configs/config.yaml +++ b/configs/config.yaml @@ -7,10 +7,10 @@ app: openai: # Prefer environment variables in real deployments. # OPENAI_API_KEY must be set; OPENAI_BASE_URL optional (for DeepSeek / other gateways). - api_key_env: "OPENAI_API_KEY" - base_url_env: "OPENAI_BASE_URL" + api_key_env: "sk-85880595fc714d63bfd0b025e917bd26" + base_url_env: "https://dashscope.aliyuncs.com/compatible-mode/v1" # Example: "gpt-4o-mini" / "gpt-4o" / gateway specific names - model: "gpt-4o-mini" + model: "qwen3.5-plus" script_gen: # Narration length constraint per scene (Chinese chars approx) diff --git a/dev.sh b/dev.sh index f9bec04..3021d6e 100755 --- a/dev.sh +++ b/dev.sh @@ -21,15 +21,17 @@ case "$CMD" in # Start in background, then wait for Node self-check + health endpoint. docker compose up -d --build "$@" echo "[dev] waiting for server health..." - deadline=$((SECONDS + 90)) + # ComfyUI first startup may take longer while preparing custom nodes. + HEALTH_TIMEOUT_SECONDS="${HEALTH_TIMEOUT_SECONDS:-300}" + deadline=$((SECONDS + HEALTH_TIMEOUT_SECONDS)) ok=0 while [ $SECONDS -lt $deadline ]; do if curl -fsS "http://127.0.0.1:3000/api/health" >/dev/null 2>&1; then ok=1 break fi - # If container exited, fail fast. - if ! docker compose ps --status running | grep -q "aivideo"; then + # Fail fast only if container actually exited (avoid mis-detecting "starting" state). + if docker compose ps --status exited | grep -q "aivideo"; then break fi sleep 1 diff --git a/docker-compose.yml b/docker-compose.yml index 1eb1b46..3060a5f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: depends_on: - comfyui environment: - - OPENAI_API_KEY=${OPENAI_API_KEY} - - OPENAI_BASE_URL=${OPENAI_BASE_URL} + - OPENAI_API_KEY=${OPENAI_API_KEY:-} + - OPENAI_BASE_URL=${OPENAI_BASE_URL:-} - PORT=3000 volumes: - ./:/app @@ -16,14 +16,11 @@ services: # Default: Docker Hub (anonymous pull). GHCR comfyanonymous image often returns "denied" without login. # Override: COMFYUI_IMAGE=ghcr.io/... after `docker login ghcr.io` comfyui: - image: ${COMFYUI_IMAGE:-jamesbrink/comfyui:latest} - environment: - - CLI_ARGS=--listen 0.0.0.0 --port 8188 + # CPU-friendly default image for non-NVIDIA development machines. + # Override with COMFYUI_IMAGE to switch back to a GPU image. + image: ${COMFYUI_IMAGE:-ardenius/comfyui-cpu:latest} + # Force bind to all interfaces so other containers (and `check_comfy`) can reach it. + # Works with the default ardenius/comfyui-cpu image layout (/ComfyUI-cpu/main.py). + command: ${COMFYUI_COMMAND:-python3 /ComfyUI-cpu/main.py --cpu --cpu-vae --listen 0.0.0.0 --port 8188} ports: - "8188:8188" - volumes: - - ./ComfyUI/user:/comfyui/user - - ./ComfyUI/models:/comfyui/models - - ./ComfyUI/custom_nodes:/comfyui/custom_nodes - - ./ComfyUI/output:/comfyui/output - - ./ComfyUI/input:/comfyui/input diff --git a/server/index.js b/server/index.js index 6ea8386..10a0480 100644 --- a/server/index.js +++ b/server/index.js @@ -60,7 +60,15 @@ function sseSend(res, event, data) { } function newTaskId() { - return crypto.randomUUID(); + // `crypto.randomUUID()` exists on newer Node versions; fall back for older runtimes. + if (crypto && typeof crypto.randomUUID === "function") return crypto.randomUUID(); + + const bytes = crypto.randomBytes(16); + // UUID v4: set version and variant bits. + bytes[6] = (bytes[6] & 0x0f) | 0x40; + bytes[8] = (bytes[8] & 0x3f) | 0x80; + const hex = bytes.toString("hex"); + return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`; } function taskDir(taskId) { @@ -285,12 +293,20 @@ app.post("/api/render", (req, res) => { async function runSelfCheck() { const py = process.env.PYTHON_BIN || "python3.10"; - const checks = [ - { name: "check_comfy", args: ["scripts/check_comfy.py"] }, - { name: "inspect_comfy_node", args: ["scripts/inspect_comfy_node.py"] }, - ]; + const selfCheckTimeoutMs = Number(process.env.SELF_CHECK_TIMEOUT_MS || 300000); + const workflowApiPath = path.join(repoRoot, "workflow_api.json"); + const requireWorkflow = String(process.env.REQUIRE_WORKFLOW || "").trim() === "1"; + + const checks = [{ name: "check_comfy", args: ["scripts/check_comfy.py"] }]; + if (fs.existsSync(workflowApiPath) || requireWorkflow) { + checks.push({ name: "inspect_comfy_node", args: ["scripts/inspect_comfy_node.py"] }); + } else { + console.warn( + `[server self-check] workflow_api.json not found at ${workflowApiPath}; skipping inspect_comfy_node (set REQUIRE_WORKFLOW=1 to enforce).` + ); + } for (const c of checks) { - const deadline = Date.now() + 90_000; + const deadline = Date.now() + selfCheckTimeoutMs; let lastErr = ""; while (Date.now() < deadline) { try { diff --git a/server/public/index.html b/server/public/index.html index a10cf62..66df199 100644 --- a/server/public/index.html +++ b/server/public/index.html @@ -38,6 +38,19 @@
+ + + @@ -94,7 +107,7 @@ showToast(m); }); es.addEventListener("task", (e) => { - try { setTaskId(JSON.parse(e.data).task_id || ""); } catch { } + try { setTaskId(JSON.parse(e.data).task_id || ""); } catch (err) { } }); es.addEventListener("done", (e) => { appendLog("[done] exit_code=" + e.data); @@ -210,7 +223,7 @@ } const data = dataLines.join("\n"); if (event === "task") { - try { setTaskId(JSON.parse(data).task_id || ""); } catch { } + try { setTaskId(JSON.parse(data).task_id || ""); } catch (err) { } } else if (event === "prog") { appendLog("[prog] " + data); } else if (event === "error") {