panrouter 5.4.4 → 5.4.5
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/package.json +1 -1
- package/pool-worker.mjs +12 -6
package/package.json
CHANGED
package/pool-worker.mjs
CHANGED
|
@@ -203,13 +203,19 @@ function handleUpgrade() {
|
|
|
203
203
|
killPort(SERVER_PORT);
|
|
204
204
|
|
|
205
205
|
if (oldVersion !== newVersion) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
log(`版本变更: v${oldVersion} → v${newVersion},升级并重启`, "OK");
|
|
207
|
+
|
|
208
|
+
// Windows 下当前进程锁住了 npm 目录 → 先 exit 释放锁再 npm install
|
|
209
|
+
// 用 start /b 提交一个后台脚本,等 2 秒(进程退出锁释放)后执行升级 + 启动
|
|
210
|
+
// start /b 的输出会打到当前终端,用户能看到进度
|
|
211
|
+
if (process.platform === 'win32') {
|
|
212
|
+
const cmd = `start /b cmd /c "@ping 127.0.0.1 -n 3 >nul && npm install -g panrouter@latest && panrouter --pool"`;
|
|
213
|
+
try { execSync(cmd, { stdio: 'pipe', timeout: 5000, shell: true }); } catch {}
|
|
214
|
+
log("升级脚本已提交 (当前进程退出后自动执行),旧进程退出", "OFF");
|
|
215
|
+
process.exit(0);
|
|
216
|
+
}
|
|
212
217
|
|
|
218
|
+
// Unix 可以直接 spawn(不会锁)
|
|
213
219
|
spawn(process.execPath, [process.argv[1], "--pool"], {
|
|
214
220
|
cwd: __dirname,
|
|
215
221
|
stdio: "inherit",
|