MCPcopy Index your code
hub / github.com/inkeep/open-knowledge / parseLock

Function parseLock

packages/server/src/process-lock.ts:76–88  ·  view source on GitHub ↗
(lockPath: string, logPrefix: string)

Source from the content-addressed store, hash-verified

74}
75
76function parseLock(lockPath: string, logPrefix: string): ProcessLockMetadata | null {
77 try {
78 const parsed = JSON.parse(readFileSync(lockPath, 'utf-8'));
79 if (parsed && typeof parsed === 'object' && isValidLockPid((parsed as { pid?: unknown }).pid)) {
80 return parsed as ProcessLockMetadata;
81 }
82 console.warn(`${logPrefix} Corrupt lock file at ${lockPath} — replacing`);
83 return null;
84 } catch {
85 console.warn(`${logPrefix} Corrupt lock file at ${lockPath} — replacing`);
86 return null;
87 }
88}
89
90export function acquireProcessLock(opts: {
91 lockName: LockName;

Callers 1

acquireProcessLockFunction · 0.85

Calls 3

isValidLockPidFunction · 0.90
parseMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected