mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-10 21:42:37 +08:00
fix python
This commit is contained in:
parent
57d1bba5eb
commit
e09c8a351f
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,3 +14,4 @@ venv/
|
|||||||
/web/extensions/*
|
/web/extensions/*
|
||||||
!/web/extensions/logging.js.example
|
!/web/extensions/logging.js.example
|
||||||
!/web/extensions/core/
|
!/web/extensions/core/
|
||||||
|
/tests-ui/data/object_info.json
|
||||||
@ -1,68 +1,71 @@
|
|||||||
const { spawn } = require("child_process");
|
const { spawn } = require("child_process");
|
||||||
const { resolve } = require("path");
|
const { resolve } = require("path");
|
||||||
const { writeFile } = require("fs");
|
const { writeFile, existsSync } = require("fs");
|
||||||
const http = require("http");
|
const http = require("http");
|
||||||
|
|
||||||
async function setup() {
|
async function setup() {
|
||||||
// Wait up to 30s for it to start
|
// Wait up to 30s for it to start
|
||||||
let success = false;
|
let success = false;
|
||||||
let child;
|
let child;
|
||||||
for (let i = 0; i < 30; i++) {
|
for (let i = 0; i < 30; i++) {
|
||||||
try {
|
try {
|
||||||
await new Promise((res, rej) => {
|
await new Promise((res, rej) => {
|
||||||
http
|
http
|
||||||
.get("http://127.0.0.1:8188/object_info", (resp) => {
|
.get("http://127.0.0.1:8188/object_info", (resp) => {
|
||||||
let data = "";
|
let data = "";
|
||||||
resp.on("data", (chunk) => {
|
resp.on("data", (chunk) => {
|
||||||
data += chunk;
|
data += chunk;
|
||||||
});
|
});
|
||||||
resp.on("end", () => {
|
resp.on("end", () => {
|
||||||
// Modify the response data to add some checkpoints
|
// Modify the response data to add some checkpoints
|
||||||
const objectInfo = JSON.parse(data);
|
const objectInfo = JSON.parse(data);
|
||||||
objectInfo.CheckpointLoaderSimple.input.required.ckpt_name[0] = ["model1.safetensors", "model2.ckpt"];
|
objectInfo.CheckpointLoaderSimple.input.required.ckpt_name[0] = ["model1.safetensors", "model2.ckpt"];
|
||||||
|
|
||||||
data = JSON.stringify(objectInfo, undefined, "\t");
|
data = JSON.stringify(objectInfo, undefined, "\t");
|
||||||
|
|
||||||
writeFile(
|
writeFile(
|
||||||
"data/object_info.json",
|
"data/object_info.json",
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
encoding: "utf8",
|
encoding: "utf8",
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
rej(err);
|
rej(err);
|
||||||
} else {
|
} else {
|
||||||
res();
|
res();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
res();
|
);
|
||||||
});
|
res();
|
||||||
})
|
});
|
||||||
.on("error", rej);
|
})
|
||||||
});
|
.on("error", rej);
|
||||||
success = true;
|
});
|
||||||
break;
|
success = true;
|
||||||
} catch (error) {
|
break;
|
||||||
if (i === 0) {
|
} catch (error) {
|
||||||
// Start the server on first iteration if it fails to connect
|
if (i === 0) {
|
||||||
console.log("Starting ComfyUI server...");
|
// Start the server on first iteration if it fails to connect
|
||||||
|
console.log("Starting ComfyUI server...");
|
||||||
|
|
||||||
const python = resolve("../../python_embeded/python.exe");
|
let python = resolve("../../python_embeded/python.exe");
|
||||||
child = spawn(python, ["-s", "ComfyUI/main.py", "--cpu"], { cwd: "../.." });
|
if (!existsSync(python)) {
|
||||||
|
python = "python";
|
||||||
}
|
}
|
||||||
await new Promise((r) => {
|
child = spawn(python, ["-s", "ComfyUI/main.py", "--cpu"], { cwd: "../.." });
|
||||||
setTimeout(r, 1000);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
await new Promise((r) => {
|
||||||
|
setTimeout(r, 1000);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
child?.kill();
|
child?.kill();
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw new Error("Waiting for server timed out...");
|
throw new Error("Waiting for server timed out...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
Loading…
Reference in New Issue
Block a user