fix(credential-cache): 允许当前进程继续运行当检测到自身锁文件时
当检测到锁文件属于当前进程时不再抛出错误,而是允许继续运行。这解决了当进程意外重启时可能出现的锁文件冲突问题。
This commit is contained in:
parent
a6c42143d0
commit
b33ff03e1f
1 changed files with 6 additions and 1 deletions
|
|
@ -103,7 +103,12 @@ export class CredentialCacheManager {
|
||||||
// 检查进程是否还在运行
|
// 检查进程是否还在运行
|
||||||
try {
|
try {
|
||||||
process.kill(pid, 0); // 0 信号仅检查进程存在性
|
process.kill(pid, 0); // 0 信号仅检查进程存在性
|
||||||
throw new Error(`[CredentialCache] Another instance is running (PID: ${pid}). Please stop it first.`);
|
// 如果进程存在,检查是否是当前进程
|
||||||
|
if (pid === process.pid) {
|
||||||
|
console.log(`[CredentialCache] Lock file belongs to current process (PID: ${pid}), continuing...`);
|
||||||
|
} else {
|
||||||
|
throw new Error(`[CredentialCache] Another instance is running (PID: ${pid}). Please stop it first.`);
|
||||||
|
}
|
||||||
} catch (killError) {
|
} catch (killError) {
|
||||||
if (killError.code === 'ESRCH') {
|
if (killError.code === 'ESRCH') {
|
||||||
// 进程已死亡,可以继续
|
// 进程已死亡,可以继续
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue