(input: {
hostname: string;
port: number;
pid: number;
scopeDir: string | null;
})
| 104 | // --------------------------------------------------------------------------- |
| 105 | |
| 106 | export 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 | |
| 134 | const parseRecord = (raw: string): DaemonRecord | null => { |
| 135 | let parsed: unknown; |
no test coverage detected