scheduler-gateway/scripts/start-detached.mjs
Liuxinyu176 bbb364cd69 feat: DSH 调度网关(互联网关)v6.0.0 — 四模型合并版 R1+R2+R3
- 零第三方依赖,Node >=20 原生 ESM
- 团队式编排引擎:拆解/路由/执行/审查/合并全真实 LLM
- 阶段心跳、单一权威清单守卫、all-keys-failed 如实上报
- H4 会话视图/amend/watchdog 有界重试/产物区 artifacts.json
- H5 零依赖三栏控制台
2026-10-09 23:20:27 +08:00

31 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Windows 可靠的后台启动器:
* node scripts/start-detached.mjs <args...>
* 以 detached+unref 方式拉起同目录 cli-live.js / cli-nodes.js,不随终端会话消亡。
*/
import { spawn } from "node:child_process";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { openSync } from "node:fs";
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const args = process.argv.slice(2);
if (!args.length) { console.error("用法: node scripts/start-detached.mjs server | node-native | node-adapter [额外参数...]"); process.exit(1); }
const MAP = {
"server": ["src/cli-live.js", "server"],
"node-native": ["src/cli-nodes.js", "native"],
"node-adapter": ["src/cli-live.js", "node-adapter"],
};
const target = MAP[args[0]] ? [...MAP[args[0]], ...args.slice(1)] : ["src/cli-nodes.js", ...args];
const log = openSync(resolve(ROOT, "_run", "detached.log"), "a");
const child = spawn(process.execPath, target, {
cwd: ROOT,
detached: true,
stdio: ["ignore", log, log],
env: { ...process.env, HOST: process.env.HOST || "0.0.0.0" }, // 默认双栈,远端可连
});
child.unref();
console.log("已脱离启动 pid=" + child.pid + ": " + target.join(" "));