feat: integrate pi rust lab runtime
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
* - MNOTE_OPENHUB_DISABLE_GIT_SNAPSHOT_RESTORE:默认 "1",禁用 OpenHub Git snapshot/restore/revert 写链
|
||||
* - MNOTE_CONTROL_PLANE_BACKEND:控制面后端,默认 libsql-local;可设 turso-remote / turso-local-replica / turso-synced
|
||||
* - MNOTE_TURSO_LOCAL_PATH:libsql-local 本地库路径,默认 /mnt/Data1T/Mnote_data/control-plane/control-plane-libsql.db
|
||||
* - MNOTE_PAGE_AI_PI_WARMUP:设为 "1" or "true" 时,在 mnote-web 可用后预启动 Pi Lab runtime / MCP cache
|
||||
* - MNOTE_PAGE_AI_PI_WARMUP_SEND:设为 "1" or "true" 时,额外发送一次轻量 prompt 预热模型首包(会产生真实模型请求)
|
||||
* - PYTHON_BIN:只在 BACKEND_CMD 未覆盖时,设置 Python 可执行文件,默认 "python"
|
||||
*/
|
||||
|
||||
@@ -28,6 +30,7 @@ const { spawn, execSync } = require("child_process");
|
||||
const path = require("path");
|
||||
const net = require("net");
|
||||
const fs = require("fs");
|
||||
const { runPiLabWarmup } = require("./lib/pi-lab-warmup");
|
||||
|
||||
const rootDir = path.resolve(__dirname, "..");
|
||||
const backendDir = path.join(rootDir, "wolai-backend");
|
||||
@@ -730,6 +733,29 @@ function startTask(task) {
|
||||
children.push(child);
|
||||
}
|
||||
|
||||
function schedulePiLabWarmup(frontendUrl) {
|
||||
if (!isEnabledEnv(mergedEnv.MNOTE_PAGE_AI_PI_WARMUP)) return;
|
||||
const warmupEnv = {
|
||||
...mergedEnv,
|
||||
MNOTE_PAGE_AI_PI_WARMUP_BASE_URL: mergedEnv.MNOTE_PAGE_AI_PI_WARMUP_BASE_URL || frontendUrl,
|
||||
};
|
||||
runPiLabWarmup(warmupEnv, {
|
||||
rootDir,
|
||||
log: (message) => logPrefix("pi-warmup", message),
|
||||
}).then((result) => {
|
||||
if (result.skipped) {
|
||||
logPrefix("pi-warmup", `已跳过:${result.reason || "disabled"}`);
|
||||
return;
|
||||
}
|
||||
logPrefix(
|
||||
"pi-warmup",
|
||||
`完成:session=${result.sessionId} send=${result.sendEnabled ? "1" : "0"} elapsedMs=${result.elapsedMs}`,
|
||||
);
|
||||
}).catch((error) => {
|
||||
logPrefix("pi-warmup", `失败但不阻塞 dev-hot:${error.message}`);
|
||||
});
|
||||
}
|
||||
|
||||
function shutdown(code) {
|
||||
if (shuttingDown) {
|
||||
return;
|
||||
@@ -857,6 +883,7 @@ async function main() {
|
||||
for (const task of tasks) {
|
||||
startTask(task);
|
||||
}
|
||||
schedulePiLabWarmup(frontendUrl);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
@@ -881,6 +908,7 @@ module.exports = {
|
||||
resolveOpenHubHealthPlan,
|
||||
resolveRuntimePlan,
|
||||
resolveBackendExecutable,
|
||||
schedulePiLabWarmup,
|
||||
shouldStartBackend,
|
||||
shouldStartOpenHub,
|
||||
stopStaleMnoteWebCargoProcesses,
|
||||
|
||||
Reference in New Issue
Block a user