MCPcopy Index your code
hub / github.com/callstack/agent-device / clearStaleProcessLock

Function clearStaleProcessLock

src/utils/process-lock.ts:68–93  ·  view source on GitHub ↗
(
  lockDirPath: string,
  ownerFilePath: string,
  ownerGraceMs: number,
)

Source from the content-addressed store, hash-verified

66}
67
68function clearStaleProcessLock(
69 lockDirPath: string,
70 ownerFilePath: string,
71 ownerGraceMs: number,
72): boolean {
73 let ownerStats: fs.Stats | null = null;
74 try {
75 ownerStats = fs.statSync(lockDirPath);
76 } catch {
77 return true;
78 }
79
80 const owner = readProcessLockOwner(ownerFilePath);
81 if (owner) {
82 if (isLiveProcessLockOwner(owner)) {
83 return false;
84 }
85 fs.rmSync(lockDirPath, { recursive: true, force: true });
86 return true;
87 }
88 if (Date.now() - ownerStats.mtimeMs < ownerGraceMs) {
89 return false;
90 }
91 fs.rmSync(lockDirPath, { recursive: true, force: true });
92 return true;
93}
94
95function readProcessLockOwner(ownerFilePath: string): ProcessLockOwner | null {
96 try {

Callers 1

acquireProcessLockFunction · 0.85

Calls 2

readProcessLockOwnerFunction · 0.85
isLiveProcessLockOwnerFunction · 0.85

Tested by

no test coverage detected