fix: 修复bug

This commit is contained in:
Daniel
2026-03-25 16:59:05 +08:00
parent a2f224d01f
commit 34786b37c7
5 changed files with 53 additions and 25 deletions

View File

@@ -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)

8
dev.sh
View File

@@ -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

View File

@@ -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

View File

@@ -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 {

View File

@@ -38,6 +38,19 @@
<body>
<div id="root"></div>
<!-- Suppress noisy in-browser Babel warning (dev-only). -->
<script>
(function () {
const ow = console.warn && console.warn.bind ? console.warn.bind(console) : console.warn;
if (!ow) return;
console.warn = function () {
const first = arguments && arguments.length ? String(arguments[0] || "") : "";
if (first.includes("in-browser Babel transformer")) return;
return ow.apply(console, arguments);
};
})();
</script>
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script crossorigin src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
@@ -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") {