MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / writeDaemonPointer

Function writeDaemonPointer

apps/cli/src/daemon-state.ts:238–267  ·  view source on GitHub ↗
(input: {
  hostname: string;
  port: number;
  pid: number;
  scopeId: string;
  scopeDir: string | null;
  token: string;
})

Source from the content-addressed store, hash-verified

236 });
237
238export const writeDaemonPointer = (input: {
239 hostname: string;
240 port: number;
241 pid: number;
242 scopeId: string;
243 scopeDir: string | null;
244 token: string;
245}): Effect.Effect<void, PlatformError, FileSystem.FileSystem | Path.Path> =>
246 Effect.gen(function* () {
247 const fs = yield* FileSystem.FileSystem;
248 const path = yield* Path.Path;
249 const dataDir = resolveDaemonDataDir(path);
250 yield* fs.makeDirectory(dataDir, { recursive: true });
251
252 const payload: DaemonPointer = {
253 version: 1,
254 hostname: canonicalDaemonHost(input.hostname),
255 port: input.port,
256 pid: input.pid,
257 startedAt: new Date().toISOString(),
258 scopeId: input.scopeId,
259 scopeDir: input.scopeDir,
260 token: input.token,
261 };
262
263 yield* fs.writeFileString(
264 daemonPointerPath(path, { hostname: input.hostname, scopeId: input.scopeId }),
265 `${JSON.stringify(payload, null, 2)}\n`,
266 );
267 });
268
269export const readDaemonPointer = (input: {
270 hostname: string;

Callers 3

runDaemonSessionFunction · 0.90

Calls 3

resolveDaemonDataDirFunction · 0.85
canonicalDaemonHostFunction · 0.85
daemonPointerPathFunction · 0.85

Tested by

no test coverage detected