@aiyiran/myclaw 1.1.73 → 1.1.74
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/index.js +13 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1975,6 +1975,19 @@ async function runServer(name) {
|
|
|
1975
1975
|
if (oldPid && !isNaN(oldPid)) {
|
|
1976
1976
|
try { process.kill(oldPid, 'SIGTERM'); } catch (e) { /* 不存在则忽略 */ }
|
|
1977
1977
|
console.log('[Server] 已终止旧进程 PID=' + oldPid);
|
|
1978
|
+
// 等待旧进程退出并释放端口(最多 5 秒)
|
|
1979
|
+
await new Promise(resolve => {
|
|
1980
|
+
let waited = 0;
|
|
1981
|
+
const interval = setInterval(() => {
|
|
1982
|
+
try {
|
|
1983
|
+
process.kill(oldPid, 0); // 检查进程是否还存在
|
|
1984
|
+
waited += 200;
|
|
1985
|
+
if (waited >= 5000) { clearInterval(interval); resolve(); }
|
|
1986
|
+
} catch {
|
|
1987
|
+
clearInterval(interval); resolve(); // 进程已退出
|
|
1988
|
+
}
|
|
1989
|
+
}, 200);
|
|
1990
|
+
});
|
|
1978
1991
|
}
|
|
1979
1992
|
} catch (e) { /* 读取失败忽略 */ }
|
|
1980
1993
|
try { fs.unlinkSync(pidFile); } catch (e) { }
|