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

Function writeDaemonRecord

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

Source from the content-addressed store, hash-verified

104// ---------------------------------------------------------------------------
105
106export const writeDaemonRecord = (input: {
107 hostname: string;
108 port: number;
109 pid: number;
110 scopeDir: string | null;
111}): Effect.Effect<void, PlatformError, FileSystem.FileSystem | Path.Path> =>
112 Effect.gen(function* () {
113 const fs = yield* FileSystem.FileSystem;
114 const path = yield* Path.Path;
115 const dataDir = resolveDaemonDataDir(path);
116
117 yield* fs.makeDirectory(dataDir, { recursive: true });
118
119 const payload: DaemonRecord = {
120 version: 1,
121 hostname: canonicalDaemonHost(input.hostname),
122 port: input.port,
123 pid: input.pid,
124 startedAt: new Date().toISOString(),
125 scopeDir: input.scopeDir,
126 };
127
128 yield* fs.writeFileString(
129 daemonRecordPath(path, { hostname: input.hostname, port: input.port }),
130 `${JSON.stringify(payload, null, 2)}\n`,
131 );
132 });
133
134const parseRecord = (raw: string): DaemonRecord | null => {
135 let parsed: unknown;

Callers 2

runDaemonSessionFunction · 0.90

Calls 3

resolveDaemonDataDirFunction · 0.85
canonicalDaemonHostFunction · 0.85
daemonRecordPathFunction · 0.85

Tested by

no test coverage detected