fix: 修复bug
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user