MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / readOwner

Function readOwner

src/workspaces/process-lock.ts:99–116  ·  view source on GitHub ↗
(lockDir: string)

Source from the content-addressed store, hash-verified

97}
98
99async function readOwner(lockDir: string): Promise<WorkspaceRootLockOwner> {
100 const raw = await readFile(join(lockDir, OWNER_FILE), 'utf8')
101 const parsed = JSON.parse(raw) as Partial<WorkspaceRootLockOwner>
102 if (
103 typeof parsed.pid !== 'number' ||
104 typeof parsed.hostname !== 'string' ||
105 typeof parsed.token !== 'string' ||
106 typeof parsed.acquiredAt !== 'string'
107 ) {
108 throw new Error('invalid workspace root lock owner')
109 }
110 return {
111 pid: parsed.pid,
112 hostname: parsed.hostname,
113 token: parsed.token,
114 acquiredAt: parsed.acquiredAt,
115 }
116}
117
118function defaultIsProcessAlive(pid: number, hostname: string): boolean {
119 if (hostname !== osHostname()) return true

Callers 2

makeLockFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected