MCPcopy
hub / github.com/coder/mux / read

Method read

src/node/services/serverLockfile.ts:86–103  ·  view source on GitHub ↗

* Read the lockfile and validate it. * Returns null if the lockfile doesn't exist or is stale (dead PID).

()

Source from the content-addressed store, hash-verified

84 * Returns null if the lockfile doesn't exist or is stale (dead PID).
85 */
86 async read(): Promise<ServerLockData | null> {
87 try {
88 await fs.access(this.lockPath);
89 const content = await fs.readFile(this.lockPath, "utf-8");
90 const data = ServerLockDataSchema.parse(JSON.parse(content));
91
92 // Validate PID is still alive
93 if (!this.isProcessAlive(data.pid)) {
94 // Clean up stale lockfile
95 await this.release();
96 return null;
97 }
98
99 return data;
100 } catch {
101 return null;
102 }
103 }
104
105 /**
106 * Release the lockfile by deleting it.

Callers 15

loadServicesFunction · 0.95
discoverServerFunction · 0.95
mainFunction · 0.95
startServerMethod · 0.95
connectToServerFunction · 0.95
discoverServerConfigFunction · 0.95
readHistoryFromOffsetMethod · 0.45
iterateForwardMethod · 0.45
iterateBackwardMethod · 0.45

Calls 4

isProcessAliveMethod · 0.95
releaseMethod · 0.95
readFileMethod · 0.65
parseMethod · 0.45

Tested by 2

collectStreamPartsFunction · 0.36
collectStreamFunction · 0.36