MCPcopy
hub / github.com/inkeep/open-knowledge / releaseProcessLock

Function releaseProcessLock

packages/server/src/process-lock.ts:314–333  ·  view source on GitHub ↗
(opts: { lockName: LockName; lockDir: string })

Source from the content-addressed store, hash-verified

312}
313
314export function releaseProcessLock(opts: { lockName: LockName; lockDir: string }): void {
315 const { lockName, lockDir } = opts;
316 const logPrefix = `[${lockName}-lock]`;
317 const lockPath = lockFilePath(lockDir, lockName);
318 if (!dropActiveLockRef(lockPath)) {
319 return;
320 }
321 if (!existsSync(lockPath)) return;
322 try {
323 const parsed = JSON.parse(readFileSync(lockPath, 'utf-8'));
324 if (!parsed || typeof parsed !== 'object' || typeof parsed.pid !== 'number') return;
325 if (parsed.pid !== process.pid) return;
326 if (typeof parsed.hostname === 'string' && parsed.hostname !== hostname()) return;
327 unlinkSync(lockPath);
328 } catch (err) {
329 console.warn(
330 `${logPrefix} Failed to release ${lockPath}: ${err instanceof Error ? err.message : String(err)}`,
331 );
332 }
333}

Callers 4

releaseServerLockFunction · 0.90
releaseUiLockFunction · 0.90
buildHandleFunction · 0.85

Calls 4

lockFilePathFunction · 0.85
dropActiveLockRefFunction · 0.85
parseMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected