@seamnet/client 0.13.4 → 0.13.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/lib/guardian.js +4 -4
- package/package.json +1 -1
package/lib/guardian.js
CHANGED
|
@@ -130,13 +130,13 @@ export async function guardianRun() {
|
|
|
130
130
|
process.exit(1);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
// 单例保证:检查 PID
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
// 单例保证:检查 PID 文件,如已有别的活进程则退出
|
|
134
|
+
const existingPid = readGuardianPid();
|
|
135
|
+
if (existingPid !== null && existingPid !== process.pid && isPidAlive(existingPid)) {
|
|
136
136
|
console.error(`Guardian already running (pid: ${existingPid}). Exiting.`);
|
|
137
137
|
process.exit(0);
|
|
138
138
|
}
|
|
139
|
-
// 写 PID
|
|
139
|
+
// 写 PID(覆盖 guardianStart 写的 child.pid),退出时清理
|
|
140
140
|
writeFileSync(PID_PATH, String(process.pid));
|
|
141
141
|
const cleanPid = () => { try { if (existsSync(PID_PATH)) unlinkSync(PID_PATH); } catch {} };
|
|
142
142
|
process.on('exit', cleanPid);
|