panrouter 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +18 -14
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -109,23 +109,27 @@ function startServer() {
|
|
|
109
109
|
|
|
110
110
|
log("..", "正在启动 Pan Router(端口 50816)...", "yellow");
|
|
111
111
|
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
detached: true
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
|
|
112
|
+
// Windows: 用 start 命令开新窗口,不依赖 node 后台进程
|
|
113
|
+
if (process.platform === "win32") {
|
|
114
|
+
execSync(`start "Pan Router" cmd /c "node "${serverPath}" & pause"`, { stdio: "pipe" });
|
|
115
|
+
} else {
|
|
116
|
+
const child = spawn("node", [serverPath], { cwd: __dirname, stdio: "ignore", detached: true });
|
|
117
|
+
child.unref();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 等待服务启动
|
|
121
|
+
for (let i = 0; i < 15; i++) {
|
|
122
122
|
try {
|
|
123
|
-
const req = http.get("http://127.0.0.1:50816/health", () => {});
|
|
123
|
+
const req = http.get("http://127.0.0.1:50816/health", (res) => {});
|
|
124
124
|
req.on("error", () => {});
|
|
125
|
+
const check = await new Promise(rs => { req.on("response", () => rs(true)); req.on("error", () => rs(false)); setTimeout(() => rs(false), 1000); });
|
|
126
|
+
if (check) { break; }
|
|
125
127
|
} catch {}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
await new Promise(rs => setTimeout(rs, 1000));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
log("OK", "Pan Router 已启动(端口 50816)", "green");
|
|
132
|
+
console.log("\n 现在可以运行: \x1b[33mclaude \"你好\"\x1b[0m\n");
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
// ─── 主流程 ──────────────────────────────────────────────────────────────
|